Arguments which are passed to the window thread
Example #1
0
        public static WindowDispatcherAsyncResult Start(XmlNode xaml, SetWindowProperties initialize, IntPtr?owner)
        {
            var done = new EventWaitHandle(false, EventResetMode.ManualReset);

            var windowArgs = new WindowArgs
            {
                WindowXaml  = xaml,
                AsyncResult = new WindowDispatcherAsyncResult(done),
                InitHandle  = new EventWaitHandle(false, EventResetMode.ManualReset),
                Initialize  = initialize,
                OwnerHandle = owner,
                //ShellDispatcher = System.Windows.Threading.Dispatcher.CurrentDispatcher,
                ShellRunspace = Runspace.DefaultRunspace
            };

            var windowThread = new Thread(WindowProc)
            {
                Name = "Presentation.Thread"
            };

            windowThread.SetApartmentState(ApartmentState.STA);
            windowThread.Start(windowArgs);

            windowArgs.InitHandle.WaitOne();

            if (windowArgs.InitException != null)
            {
                throw windowArgs.InitException;
            }

            return(windowArgs.AsyncResult);
        }
      public static WindowDispatcherAsyncResult Start(XmlNode xaml, SetWindowProperties initialize, IntPtr? owner)
      {
         var done = new EventWaitHandle(false, EventResetMode.ManualReset);

         var windowArgs = new WindowArgs()
                             {
                                WindowXaml = xaml,
                                AsyncResult = new WindowDispatcherAsyncResult(done),
                                InitHandle = new EventWaitHandle(false, EventResetMode.ManualReset),
                                Initialize = initialize,
                                OwnerHandle = owner,
                                //ShellDispatcher = System.Windows.Threading.Dispatcher.CurrentDispatcher,
                                ShellRunspace = Runspace.DefaultRunspace
                             };

         var windowThread = new Thread(WindowProc)
                               {
                                  Name = "Presentation.Thread"
                               };

         windowThread.SetApartmentState(ApartmentState.STA);
         windowThread.Start(windowArgs);

         windowArgs.InitHandle.WaitOne();

         if (windowArgs.InitException != null) throw windowArgs.InitException;

         return windowArgs.AsyncResult;

      }