0

Possible Duplicate:
Prevent multiple instances of a given app in .NET?
How can I enforce a single instance of my application?

I have a source then complie to App.exe file. I want if App.exe is running, then a person open it again, it know that it is running and close automaticly. Is there any way to do this?

**Edit: I want a code that insert to source of App.exe

Window Form**

0

1 Answer 1

1

You want to use a Mutex, like so:

bool bIsSingleInstance; using (new Mutex(true, Assembly.GetExecutingAssembly().GetName().Name, out bIsSingleInstance)) { if (bIsSingleInstance) { // START APP HERE. } } 

Note that you must NOT use 'using' if your winforms isn't blocking in the comment block.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.