How to check if multiple instances of the application are running using C# (.NET)
Here is a simple code to check if multiple instances of current application are running in the machine using System.Diagnostics
private static void check_application_process_instances()
{
Process[] oProcess;
String sModuleName;
String sProcessName;
sModuleName = Process.GetCurrentProcess().MainModule.ModuleName;
sProcessName = System.IO.Path.GetFileNameWithoutExtension(sModuleName);
oProcess = Process.GetProcessesByName(sProcessName);
if (oProcess.Length > 1 )
{
MessageBox.Show("More than one instance is running!");
}
}