how it is possible to check whether another instance of the program is running and if so stop the application before loading if there is an existing instance of it.
Solution:
write at your Main method the following code to quit the method which will kill the currently loading process instantly.
if (System.Diagnostics.Process.GetProcessesByName(
System.IO.Path.GetFileNameWithoutExtension(
System.Reflection.Assembly.GetEntryAssembly().Location)).Length > 1)
{
MessageBox.Show("Application is already running");
System.Diagnostics.Process.GetCurrentProcess().Kill();
}
Solution:
write at your Main method the following code to quit the method which will kill the currently loading process instantly.
if (System.Diagnostics.Process.GetProcessesByName(
System.IO.Path.GetFileNameWithoutExtension(
System.Reflection.Assembly.GetEntryAssembly().Location)).Length > 1)
{
MessageBox.Show("Application is already running");
System.Diagnostics.Process.GetCurrentProcess().Kill();
}
0 comments:
Post a Comment