标签:style blog http color 使用 os
1 /// <summary> 2 /// check whether other instance of the application is running. 3 /// </summary> 4 /// <returns></returns> 5 private bool TestIfAlreadyRunning() 6 { 7 Process currentProcess = Process.GetCurrentProcess(); 8 9 foreach (var process in Process.GetProcesses()) 10 { 11 // avoid check this process itself. 12 if(currentProcess.Id != process.Id) 13 { 14 //if other instance is running,the Process Name must identical. 15 if (currentProcess.ProcessName == process.ProcessName) 16 return true; 17 } 18 } 19 20 return false; 21 }
避免在同一机器上同时运行同一应用程序的多个实例,布布扣,bubuko.com
标签:style blog http color 使用 os
原文地址:http://www.cnblogs.com/robyn/p/3812515.html