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!");
}
}
How do I find Process.GetProcessesByName.
ReplyDeleteI have Visual Studio 2008 and if I import system.diagnostics and use try to find GetProcessesByName, the only options I can see are Process.GetCurrentProcess and Process.GetProcessById. What am I missing. Everyone seems to have Process.GetProcessesByName?