原文:
WPF 控制程序只能启动一次
版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/jsyhello/article/details/7411898
public partial class App : Application
{
System.Threading.Mutex mutex;
public App()
{
this.Startup += new StartupEventHandler(App_Startup);
}
void App_Startup(object sender, StartupEventArgs e)
{
bool ret;
mutex = new System.Threading.Mutex(true, "WpfMuerterrrterterttex", out ret);
if (!ret)
{
MessageBox.Show("Program has started, you can't start again!");
Environment.Exit(0);
}
}
}
感谢:http://www.cnblogs.com/xiaokang088/archive/2011/03/29/1998710.html
欢迎访问:http://121.18.78.216 适易查询分析、工作流、内容管理及项目管理演示平台