A
AnnaForEver
Guest
The issue happens when running the application in a loop on windows 10, when CPU usage is high, it will return error "Another instance of MyApplication.exe is already running" even though it is closed properly. but on windows 7, it is very stable.
The running process is as below(batch file):
SET /A a=1
:LOOP
IF %a%==5 GOTO END
"MyApplication.exe"
GOTO :LOOP
:END
If I add a delay in the loop then it can solve the problem, but i need to find the root cause, as it works very stable on windows 7, why only have issue on windows 10. Did anyone know what is the issue?
partial source code is as below:
private void Application_Closed(object sender, EventArgs e)
{
//Thread.Sleep(1);
Application.Current.Shutdown();
}
private void Application_Startup(object sender, StartupEventArgs e)
{
// Checks if another instance of MyApplication.exe is already running or not.
if (Process.GetProcessesByName(Process.GetCurrentProcess().ProcessName).Length > 1)
{
MessageBox.Show("Another instance of MyApplication.exe\nis already running.\n\nExiting ...",
"MyApplication",
MessageBoxButton.OK,
MessageBoxImage.Exclamation);
Environment.Exit((int)ErrorCodes.ExistingProcess); // Initiate shutting down of current instance.
}
.....
}
Thanks so much for your help.
Continue reading...
The running process is as below(batch file):
SET /A a=1
:LOOP
IF %a%==5 GOTO END
"MyApplication.exe"
GOTO :LOOP
:END
If I add a delay in the loop then it can solve the problem, but i need to find the root cause, as it works very stable on windows 7, why only have issue on windows 10. Did anyone know what is the issue?
partial source code is as below:
private void Application_Closed(object sender, EventArgs e)
{
//Thread.Sleep(1);
Application.Current.Shutdown();
}
private void Application_Startup(object sender, StartupEventArgs e)
{
// Checks if another instance of MyApplication.exe is already running or not.
if (Process.GetProcessesByName(Process.GetCurrentProcess().ProcessName).Length > 1)
{
MessageBox.Show("Another instance of MyApplication.exe\nis already running.\n\nExiting ...",
"MyApplication",
MessageBoxButton.OK,
MessageBoxImage.Exclamation);
Environment.Exit((int)ErrorCodes.ExistingProcess); // Initiate shutting down of current instance.
}
.....
}
Thanks so much for your help.
Continue reading...