Esempio n. 1
0
 protected override bool OnStartup(
     Microsoft.VisualBasic.ApplicationServices.StartupEventArgs e)
 {
     app = new WpfApp();
     app.Run();
     return(false);
 }
Esempio n. 2
0
        } = EventLoopMode.CodeLoop;                                                              //No plan to make publish

        static public void InternalDoEventLoop(Action initHandler)
        {
            if (initHandler != null)
            {
                PostToAppThread(initHandler);
            }

            long tickcount = 0;

            WF.Timer globaltimer = new WF.Timer();
            globaltimer.Interval = 50;
            globaltimer.Tick    += delegate
            {
                //for Form.ShowDialog(..)
                DoMessageLoopOnce();

                tickcount++;
                if (tickcount % 50 == 0 && WF.Application.OpenForms.Count == 0
#if SUPPORT_WPF
                    && (_wpfapp == null || _wpfapp.Windows.Count == 0)
#endif
                    )
                {
                    QuitWindowsEventLoop();
                    WriteDebugLine("QuitWindowsEventLoop for no Forms/Window");
                }
            };
            globaltimer.Start();

            switch (LoopMode)
            {
            case EventLoopMode.LibCef:
                WriteDebugLine("cef_run_message_loop() start.");
                LibCefInterop.cef_run_message_loop();
                WriteDebugLine("cef_run_message_loop() end.");
                break;

#if SUPPORT_WPF
            case EventLoopMode.WPF:
                WpfApp.Run();
                break;
#endif
            case EventLoopMode.WinForms:
                WF.Application.Idle += delegate
                {
                    InvokeCefMessageLoopOnce();
                };
                WF.Application.Run();
                break;

            case EventLoopMode.CodeLoop:
            default:
                while (!IsWindowsEventLoopQuitRequested)
                {
                    InvokeCefMessageLoopOnce();
                    WF.Application.DoEvents();
                    System.Threading.Thread.Sleep(1);
                }
                break;
            }

            globaltimer.Stop();

            WriteDebugLine("Existing event loop start");

            if (_app_mutex != null)
            {
                if (!_app_mutex_disposed)
                {
                    _app_mutex_disposed = true;
                    _app_mutex.Dispose();
                    WriteDebugLine("_app_mutex disposed 2.");
                }
            }

            foreach (WF.Form form in new System.Collections.ArrayList(WF.Application.OpenForms))
            {
                WriteDebugLine("Close Form [" + form.Text + "]");
                //form.Close();
                form.Dispose();
            }
#if SUPPORT_WPF
            if (_wpfapp != null)
            {
                WriteDebugLine("Check wpf windows..");
                foreach (System.Windows.Window win in _wpfapp.Windows)
                {
                    win.Close();
                }
            }
#endif

            WriteDebugLine("Existing event loop end");
        }