Cyberiafreak

"Fortunate are those who take the first steps.” ― Paulo Coelho

Single instance of an application in C#

Hi,
To achive single instance of an application in C#, use the following code:
 
[STAThread]
static void Main()
{
bool blnIsRunning;
Mutex m = new Mutex(true, "FirstLoad", out blnIsRunning);
if(blnIsRunning)
{
    Form1 mainForm = new Form1();
    Application.Run(mainForm);
}
else
{
    MessageBox.Show("Another instance is already running.");
}
}
Note: Import System.Threading
Thanks to Jayveer for Sharing this…By the way anyone knows how to create more than one instance of an application(any application)  with any tips/tools to crack this lock. I mean I have seen few application wont allow you to create multiple instance, but i want to unlock it..any idea regarding this..???
 
Mahes
Advertisements

August 29, 2006 - Posted by | .NET General

No comments yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: