Click here to Skip to main content
15,884,724 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 (2 votes)
2 Nov 2011CPOL 5.4K   1  
I really like this method, very easy to implement and understand. One minor "gotcha" about doing it this way is that it is still possible to run multiple instances under different user accounts simultaneously if the users are not administrators on the PC. If this is a scenario you need to avoid,...

I really like this method, very easy to implement and understand. One minor "gotcha" about doing it this way is that it is still possible to run multiple instances under different user accounts simultaneously if the users are not administrators on the PC. If this is a scenario you need to avoid, you can use a mutex. So, on startup, the application would:



  1. Check to see if the mutex exists already.
  2. If (1) close, else open and create the mutex.

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 --