Click here to Skip to main content
15,886,035 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.
5.00/5 (3 votes)
2 Nov 2011CPOL 8.9K   2   1
I would use a mutex object - using the process name might cause errors. Try "WaitOne" on the mutex - only the first process will be able to acquire it, and in the case of a failure, just exit.

I would use a mutex object - using the process name might cause errors. Try "WaitOne" on the mutex - only the first process will be able to acquire it, and in the case of a failure, just exit.

License

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


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

Comments and Discussions

 
GeneralReason for my vote of 5 yep thats the way to go Pin
johannesnestler24-Jan-12 6:01
johannesnestler24-Jan-12 6:01 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.