zl程序教程

您现在的位置是:首页 >  后端

当前栏目

wpf程序启动事件

2023-09-14 09:10:46 时间
public App()
        {
            this.Startup += (o, e) =>
            {
                bool isrun = false;
                Mutex m = new Mutex(true, System.Reflection.Assembly.GetExecutingAssembly().FullName, out isrun);
                if (!isrun)
                {
                    Application.Current.Shutdown();
                }
                else
                {
                    cfg = Cfg.Load();
					//show
                }
            };
            this.Exit += (o, e) =>
            {
				Cfg.Save();
                Application.Current.Shutdown();
            };

            AppDomain.CurrentDomain.UnhandledException += (o, e) =>
            {
				//(e.ExceptionObject);
            };
            this.DispatcherUnhandledException += (o, e) =>
            {
            	//e.Exception e.Handled
            };
        }
    }