In .NET, how can I prevent multiple instances of an app from running at the same time and what caveats should I consider if there are multiple ways to do it?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Use Mutex. One of the examples above using GetProcessByName has many caveats. Here is a good article on the subject:
https://web.archive.org/web/20230610150623/https://odetocode.com/blogs/scott/archive/2004/08/20/the-misunderstood-mutex.aspx