Wednesday, August 11, 2004

Ensuring a single instance of your .Net application


Ensuring a single instance of your .Net application









[STAThread]
static void Main()
{
bool ok;
m = new System.Threading.Mutex(true, "YourNameHere", out ok);
if (! ok)
{
MessageBox.Show("Another instance is already running.");
return;
}
Application.Run(new Form1());
GC.KeepAlive(m);
}
Regards,
Mitesh Mehta
http://cc.1asphost.com/miteshvmehta/

No comments: