예제 #1
0
        protected override void Run()
        {
            this.Engine.Log(LogLevel.Verbose, "Launching Sparrow.Chart.Installer");
            BootstrapperDispatcher = Dispatcher.CurrentDispatcher;
            MainViewModel viewModel = new MainViewModel(this);
            viewModel.Bootstrapper.Engine.Detect();

            if (viewModel.Bootstrapper.Command.Action == LaunchAction.Install && !isInstalled)
            {
                MainView view = new MainView();
                view.DataContext = viewModel;
                view.Closed += (sender, e) => BootstrapperDispatcher.InvokeShutdown();
                view.Show();
                isInstalled = true;
            }

            if (viewModel.Bootstrapper.Command.Action == LaunchAction.Uninstall && !isUninstalled)
            {
                MainView view = new MainView();
                view.DataContext = viewModel;
                view.Closed += (sender, e) => BootstrapperDispatcher.InvokeShutdown();
                view.Show();
                isUninstalled = true;
            }

            Dispatcher.Run();

            this.Engine.Quit(0);
        }
예제 #2
0
 public static void AppShutdownDispatcher(Dispatcher theMainDispatcher)
 {
     if (theMainDispatcher.CheckAccess())
     {
         theMainDispatcher.InvokeShutdown();
     }
     else
     {
         Dispatcher.CurrentDispatcher.Invoke(DispatcherPriority.Send, (Action)(() =>
         {
             theMainDispatcher.InvokeShutdown();
         }));
     }
 }
예제 #3
0
        // entry point for our custom UI
        protected override void Run()
        {
            try
            {
                this.Engine.Log(LogLevel.Verbose, "Launching OSA BA UX");
                BootstrapperDispatcher = Dispatcher.CurrentDispatcher;

                MainViewModel viewModel = new MainViewModel(this);
                viewModel.Bootstrapper.Engine.Detect();

                MainView view = new MainView();

                view.DataContext = viewModel;
                view.Closed += (sender, e) => BootstrapperDispatcher.InvokeShutdown();
                view.Show();

                Dispatcher.Run();
            }
            catch (Exception ex)
            {
                this.Engine.Log(LogLevel.Verbose, "Exception Caught by BA details:" + ex.Message);
                // change to use engine log
                MessageBox.Show("Exception" + ex.Message);
            }

            this.Engine.Quit(0);
        }
        private static void Show(Action action)
        {
            var startedEvent = new ManualResetEventSlim(initialState: false);

            System.Windows.Threading.Dispatcher dispatcher = null;
            var uiThread = new Thread(() =>
            {
                // Create and install a new dispatcher context
                SynchronizationContext.SetSynchronizationContext(new DispatcherSynchronizationContext(Dispatcher.CurrentDispatcher));
                dispatcher = Dispatcher.CurrentDispatcher;

                // Signal that it is initialized
                startedEvent.Set();

                // Start the dispatcher processing
                Dispatcher.Run();
            });

            // Set the apartment state
            uiThread.SetApartmentState(ApartmentState.STA);

            // Make the thread a background thread
            uiThread.IsBackground = true;

            // Start the thread
            uiThread.Start();
            startedEvent.Wait();
            dispatcher.Invoke(action);
            dispatcher.InvokeShutdown();
            uiThread.Join(1000);
            startedEvent.Dispose();
        }
예제 #5
0
        public void GetAndRunWpfDispatcher_invokeAndShutdown_invocationInDispatcherDone()
        {
            System.Windows.Threading.Dispatcher disp = null;
            var created = new ManualResetEvent(false);
            var t       = new Thread(x =>
            {
                disp = System.Windows.Threading.Dispatcher.CurrentDispatcher;
                created.Set();
                System.Windows.Threading.Dispatcher.Run();
            });

            t.SetApartmentState(ApartmentState.STA);
            t.Start();
            created.WaitOne();

            int    threadId = -1;
            bool   wasAct   = false;
            Action act      = () =>
            {
                wasAct   = true;
                threadId = Thread.CurrentThread.ManagedThreadId;
            };

            disp.Invoke(act);
            disp.InvokeShutdown();

            Assert.AreEqual(threadId, t.ManagedThreadId);
            Assert.That(wasAct, Is.True);
        }
		protected override void Run()
        {
            this.Engine.Log(LogLevel.Verbose, "Launching Firesec Bootstrapper Application UX");
            BootstrapperDispatcher = Dispatcher.CurrentDispatcher;
			MainView view = new MainView();
			view.DataContext = new MainViewModel(this);
            view.Closed += (sender, e) => BootstrapperDispatcher.InvokeShutdown();
            view.Show();
			Dispatcher.Run();
			this.Engine.Quit(0);
        }
예제 #7
0
        protected override void Run()
        {
            Engine.Log(LogLevel.Verbose, "Launching Magic Setup UX");
            BootstrapperDispatcher = Dispatcher.CurrentDispatcher;

            Window window = GetSetupWindow();

            Engine.Detect();
            window.Closed += (sender, e) => BootstrapperDispatcher.InvokeShutdown();
            window.Show();
            Dispatcher.Run();
            Engine.Quit(0);
        }
        protected override void Run()
        {
            this.Engine.Log(LogLevel.Verbose, "Launching InstallerBootstrapperApplication");
            BootstrapperDispatcher = Dispatcher.CurrentDispatcher;

            var viewModel = new MainWindowModel(this);
            viewModel.Bootstrapper.Engine.Detect();

            Util.Log("Installer running: " + this.Command.Action + " " + this.Command.Display);
            if (this.Command.Action == LaunchAction.Uninstall && this.Command.Display == Display.Embedded)
            {
                Util.Log("viewModel.Uninstall");
                viewModel.Uninstall();
                Util.Log("BootstrapperDispatcher.InvokeShutdown");
                BootstrapperDispatcher.InvokeShutdown();
            }
            else
            {
                var view = new MainWindow(viewModel);
                view.Closed += (sender, e) =>
                {
                    Util.Log("BootstrapperDispatcher.InvokeShutdown");
                    BootstrapperDispatcher.InvokeShutdown();
                    Util.Log("Engine.Quit");
                    viewModel.Dispose();
                    Engine.Quit((int)ActionResult.Success);
                };
                Util.Log("view.Show");
                view.Show();
                Util.Log("Dispatcher.Run");
                Dispatcher.Run();
            }
            Util.Log("viewModel.Dispose");
            viewModel.Dispose();

            this.Engine.Quit((int)ActionResult.Success);
        }
예제 #9
0
		protected override void Run()
		{
			this.Engine.Log(LogLevel.Verbose, "Launching custom TestBA UX");
			BootstrapperDispatcher = Dispatcher.CurrentDispatcher;

			MainViewModel viewModel = new MainViewModel(this);
			MainView view = new MainView();
			viewModel.Bootstrapper.Engine.Detect();
			view.DataContext = viewModel;
			view.Closed += (sender, e) => BootstrapperDispatcher.InvokeShutdown();
			view.Show();

			Dispatcher.Run();

			this.Engine.Quit(0);
		}
예제 #10
0
        public void WpfRunShutdown()
        {
            System.Windows.Threading.Dispatcher wpfDisp = null;
            var t = new Thread(x =>
            {
                wpfDisp = System.Windows.Threading.Dispatcher.CurrentDispatcher;
                System.Windows.Threading.Dispatcher.Run();
            });

            t.SetApartmentState(ApartmentState.STA);
            t.Start();
            bool waitRun = t.Join(TimeSpan.FromMilliseconds(200));

            Assert.False(wpfDisp.HasShutdownFinished);
            wpfDisp.InvokeShutdown();

            bool waitShutdown = t.Join(TimeSpan.FromMilliseconds(50));

            Assert.False(waitRun);
            Assert.True(wpfDisp.HasShutdownFinished);
            Assert.True(waitShutdown);
        }
        public static void Show(Bitmap expected, Bitmap actual)
        {
            using (var startedEvent = new ManualResetEventSlim(initialState: false))
            {
                System.Windows.Threading.Dispatcher dispatcher = null;
                var uiThread = new Thread(() =>
                {
                    // Create and install a new dispatcher context
                    SynchronizationContext.SetSynchronizationContext(new DispatcherSynchronizationContext(Dispatcher.CurrentDispatcher));
                    dispatcher = Dispatcher.CurrentDispatcher;

                    // Signal that it is initialized
                    // ReSharper disable once AccessToDisposedClosure
                    startedEvent.Set();

                    // Start the dispatcher processing
                    Dispatcher.Run();
                });

                // Set the apartment state
                uiThread.SetApartmentState(ApartmentState.STA);

                // Make the thread a background thread
                uiThread.IsBackground = true;

                // Start the thread
                uiThread.Start();
                startedEvent.Wait();
                dispatcher.Invoke(() =>
                {
                    var window = new ImageDiffWindow(expected, actual);
                    window.ShowDialog().IgnoreReturnValue();
                });

                dispatcher.InvokeShutdown();
                uiThread.Join(1000).IgnoreReturnValue();
            }
        }
        // entry point for our custom UI
        protected override void Run()
        {
            try
            {
                Engine.Log(LogLevel.Verbose, "Launching custom ManagedBootstrapperApplication UX");
                BootstrapperDispatcher = Dispatcher.CurrentDispatcher;

                var viewModel = new MainViewModel(this);
                Engine.Detect();

                var view = new MainView();
                view.DataContext = viewModel;
                view.Closed += (sender, e) => BootstrapperDispatcher.InvokeShutdown();
                view.Show();
                Dispatcher.Run();

                Engine.Quit(0);
            }
            catch (Exception exception)
            {
                MessageBox.Show(exception.ToString());
                Engine.Quit(0);
            }
        }