Sunday, December 2, 2012

How to: Check if another instance of the application is already running

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.


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.Reflection.Assembly.GetEntryAssembly().Location)).Length > 1)
  MessageBox.Show("Application is already running");

No comments:

Post a Comment