Exemplo n.º 1
0
        protected override void OnExiting(object sender, EventArgs args)
        {
            // When we exit the application, we must manually end the WPF thread. Otherwise,
            // the WPF part continues to run and keeps the application alive.
            WpfEnvironment.Shutdown();

            base.OnExiting(sender, args);
        }
Exemplo n.º 2
0
        private void OpenWpfWindow()
        {
            // WPF windows need to run on a separate thread. This thread is prepared by
            // the WpfEnvironment class. (Redundant calls of Startup() are no problem.)
            WpfEnvironment.Startup(Window.Handle);

            // WPF windows must be created and handled on the WPF thread. From the WpfEnvironment
            // class we can get the Dispatcher of the WPF thread. We can use it to execute actions
            // on the WPF thread.
            WpfEnvironment.Dispatcher.Invoke((Action)(() =>
            {
                _wpfWindow = new WpfWindow {
                    GraphicsService = _graphicsManager
                };
                _wpfWindow.Closing += OnWindowClosing;
                _wpfWindow.Show();
            }));
        }