3

Possible Duplicate:
What is the correct way to create a single instance application?

How can I define my application to open only one time after click on its exe file over and over?

Community
  • 1
  • 1
user1269592
  • 691
  • 3
  • 12
  • 24

2 Answers2

3

There are several related questions on Stack Overflow for Single Instance Applications:

This one seems to be the most apropriate: What is the correct way to create a single-instance application?

Community
  • 1
  • 1
Uwe Keim
  • 39,551
  • 56
  • 175
  • 291
1

I've always done this at the application's entry point:

bool onlyInstance = false;

Mutex m = new Mutex(true, "MyUniqueMutextName", out onlyInstance);
if (!onlyInstance)
{
    return;
}

GC.KeepAlive(m);
Jon
  • 150
  • 3