您的位置:首页 > 其它

WPF学习笔记 - 如何用WPF创建单实例应用程序

2015-03-06 11:32 330 查看
使用一个已命名的(操作系统范围的)互斥量。

bool mutexIsNew;

using(System.Threading.Mutex m = new System.Threading.Mulex(true, uniqueName, out mutexIsNew))

{

if(mutexIsNew)

{

//This is the first instance, can run the appliacation

}

else

{

//There is an instance running, exit. }

}

因为是操作系统范围的,所以需要确定参数uniqueName指定的名字不会被其他应用程序使用。
http://blog.csdn.net/cs_oldhorse/article/details/6803569
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐