Click here to Skip to main content
15,892,298 members
Articles / Programming Languages / C#
Alternative
Tip/Trick

Video tip C#: Ensure only one instance is running

Rate me:
Please Sign up or sign in to vote.
0.00/5 (No votes)
11 Dec 2011CPOL 5.8K  
[STAThread]s...
C#
[STAThread]
static void Main()
{
    bool singLeInstance = true;
    Mutex mutex = new Mutex(true, "UniqueApplicationName", out onlyInstance);
    if (!singleInstance) {
    return;
}
else
{
    Application.EnableVisualStyles();
    Application.SetCompatibleTextRenderingDefault(false);
    Application.Run(new Form1());
}

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
United States United States
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
-- There are no messages in this forum --