Sunday, 30 December 2012 13:54

how to prevent running multiple application instances same time

Written by 
Rate this item
(0 votes)

if you want to prevent running multiple instance
of the same c# application then check the
following lines.It's sometime necessary to prevent
running multiple instances of the same application.

following c# codes shows how to do that -

in your main form under Main() method add the
following method-

static void Main()

then add the method -

static void checkApplicationInstance()
string currPrsName = Process.GetCurrentProcess().ProcessName;
Process[] allProcessWithThisName =
if (allProcessWithThisName.Length > 1)
MessageBox.Show("your application is already
running\nor might be just restarting.\ntry again.",
"your app name", MessageBoxButtons.OK, MessageBoxIcon.Information);
Application.Run(new mainForm());


Read 1305 times
Super User

Email This email address is being protected from spambots. You need JavaScript enabled to view it.
Login to post comments