/// <summary>
/// 检测进程,只能启动一个
/// </summary>
static void CheckProcess()
{
Process currentProcess = Process.GetCurrentProcess();
foreach (Process item in Process.GetProcessesByName(currentProcess.ProcessName))
{
if (item.Id != currentProcess.Id &&
(item.StartTime - currentProcess.StartTime).TotalMilliseconds <= 0)
{
item.Kill();
item.WaitForExit();
break;
}
}
}
————————————————
版权声明:本文为CSDN博主「wqq1027」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/wqq1027/article/details/80939903