WPF学习笔记

使用一个已命名的(操作系统范围的)互斥量。

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

原文地址:https://www.cnblogs.com/tianciliangen/p/4317746.html