コード例 #1
0
        private static void Application_ApplicationExit(object sender, EventArgs e)
        {
            //to kill subprocess in windows . because on windows when application exited,will left a subprocess can not auto shutdown.

            if (CfxRuntime.PlatformOS == CfxPlatformOS.Windows)
            {
                var current = Process.GetCurrentProcess();

                var processName = current.ProcessName;

                var sublist = Process.GetProcessesByName(processName);

                var realSublist = sublist.Where(p => p.Id != current.Id).ToList();

                foreach (var process in realSublist)
                {
                    try
                    {
                        process.Kill();
                    }
                    catch (Exception ex)
                    {
                    }
                }
            }
            else
            {
                CfxRuntime.QuitMessageLoop();
            }

            CfxRuntime.Shutdown();
        }