WPF学习笔记 - 如何用WPF创建单实例应用程序
2015-03-06 11:32
337 查看
使用一个已命名的(操作系统范围的)互斥量。
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
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
相关文章推荐
- WPF学习笔记 - 如何用WPF创建单实例应用程序
- 设计模式学习笔记:就一句话的创建实例是如何演变成工厂模式的?
- WPF and Silverlight 学习笔记(五):WPF应用程序管理
- Smart Client学习笔记(2) 创建专业用户界面的Windows Form应用程序
- 转:CXF学习笔记二:如何在Tomcat中创建、发布和访问基于CXF的服务
- VC++学习笔记之MFC应用程序创建/执行顺序和MFC运行机制
- Sharepoint学习笔记---Sandbox Solution-- Full Trust Proxy--开发实例之(1、创建一个能访问DataBase的Full Trust Proxy)
- WPF学习之一:应用程序创建
- WPF:如何实现单实例的应用程序(Single Instance)
- ArcGIS Mobile 9.4学习笔记八之如何设计和创建移动地图
- WPF学习笔记 - WPF多线程应用程序
- WPF and Silverlight 学习笔记(四):WPF应用程序结构——HelloWorld
- ArcGIS Mobile 9.4学习笔记八之如何设计和创建移动地图
- SilverLight学习笔记--实际应用(一)(6):手把手建立一个Silverlight应用程序之创建数据校验类3
- iPhone开发学习笔记[3/50]-使用工具栏创建简单的多视图应用程序
- Jpcap包的学习笔记(五)如何使用JpcapCaptor实例来捕捉网络数据包(上部)
- ADO.NET学习笔记——如何手动创建类型化DataSet对象
- CXF学习笔记一:如何创建、发布和访问基于CXF的服务
- Smart Client学习笔记(7) 使用多线程创建高响应智能客户端应用程序
- Silverlight学习笔记1:创建一个Silverlight应用程序