标签:static ext sse pat nbsp pdo second run kill
public static Process RunningInstance()
{
Process currentProcess = Process.GetCurrentProcess();
Process[] sameProcess = Process.GetProcessesByName(System.IO.Path.GetFileNameWithoutExtension(AppDomain.CurrentDomain.BaseDirectory + currentProcess.ProcessName));
if (sameProcess != null && sameProcess.Length > 0)
{
// 遍历正在有相同名字运行的例程
foreach (Process process in sameProcess)
{
// 忽略现有的例程
if (process.Id != currentProcess.Id && (process.StartTime - currentProcess.StartTime).TotalMilliseconds <= 0)
{
process.Kill();
return null;
//return process;
}
}
}
return null;
}
标签:static ext sse pat nbsp pdo second run kill
原文地址:http://www.cnblogs.com/yi-u/p/7940321.html