限制程序重复启动:
bool noAny; System.Threading.Mutex m = new System.Threading.Mutex(true, Application.ProductName, out noAny); if (!noAny) { MessageBox.Show("程序已在运行,禁止重复启动!", "提示"); System.Threading.Thread.Sleep(500); Environment.Exit(1); }
z全局异常捕获:
//设置应用程序处理异常方式 Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException); //UI线程异常 Application.ThreadException += new System.Threading.ThreadExceptionEventHandler(Application_ThreadException); //非UI线程异常, AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);
标签:Threading,重复,捕获,System,noAny,Application,new,全局,异常 From: https://www.cnblogs.com/cfsl/p/17635916.html