Could someone show how it is possible to check whether another instance of the program (e.g. test.exe) is running and if so stop the application from loading if there is an existing instance of 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.
Want some serious code? Here it is.
This works for any application (any name) and will become
trueif there is another instance running of the same application.Edit: To fix your needs you can use either of these:
from your Main method to quit the method… OR
which will kill the currently loading process instantly.
You need to add a reference to System.Core.dll for the
.Count()extension method. Alternatively, you can use the.Lengthproperty.