Jamie Cansdale's Radio Weblog


Subscribe to "Jamie Cansdale's Radio Weblog" in Radio UserLand.

Click to see the XML version of this web page.

Click here to send an email to the editor of this weblog.


22 January 2003
 

MDAC 2.7 RTM Refresh [MSDN Recently Posted]
7:59:43 PM    

There can be only one....

This is an old trick, but updated for the .NET world.

Question, how do you keep more than one instance of an app from running (this can be especially useful for Terminal Server scenarios).

Mutex m;
public Form1()
{
    InitializeComponent();
    bool gotIt = false;
    m = new Mutex(true, "SomethingReallyUnique", out gotIt);
    if (!gotIt)
    {
        MessageBox.Show("This application is already running.");
        Application.Exit();
    }
}
 
 
[Sean 'Early' Campbell & Scott 'Adopter' Swigart's Radio Weblog]
11:58:10 AM    


Click here to visit the Radio UserLand website. © Copyright 2003 Jamie Cansdale.
Last update: 01/02/2003; 11:09:37.
January 2003
Sun Mon Tue Wed Thu Fri Sat
      1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31  
Dec   Feb