如何以编程方式检查我的WPF应用程序现在是否正在工作?,就像VB中的App.PrevInstance一样。 请给我一个简单的方法,我是初学者。检查当前的WPF应用程序是否正在运行?
这里我的代码,
protected override void OnStartup(StartupEventArgs e)
{
base.OnStartup(e);
var runningProcessByName = Process.GetProcessesByName("TCLCGFP");
if (runningProcessByName.Length == 0)
{
//Process.Start("TCLCGFP.exe");
new TraacsClcProcess();
}
else
{
MessageBox.Show("Application is already Running.","TCLCGFP",MessageBoxButton.OK,MessageBoxImage.Information);
}
Environment.Exit(0);
}
它总是显示应用程序已经运行:P
可能重复[检查如果Windows应用程序运行](http://stackoverflow.com/questions/4722198/checking-if-windows-application-is-running) – demonplus
我正在寻找简单的代码,如在VB中使用App.PrevInstance。 –
然后更新您的问题与确切的细节,你需要什么和你已经尝试 – demonplus