Windows Phone Developers

Showing posts with label Check Multiple Instances using C#. Show all posts
Showing posts with label Check Multiple Instances using C#. Show all posts

Wednesday, December 23, 2009

Check Multiple Instances of an Application using C#

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!");

}

}


Digg Technorati Delicious StumbleUpon Reddit BlinkList Furl Mixx Facebook Google Bookmark Yahoo
ma.gnolia squidoo newsvine live netscape tailrank mister-wong blogmarks slashdot spurl StumbleUpon