I developed an application that is hosted in one server. Many users access to it via Remote Desktop connection, but sometimes I saw in the task manager that the same user has opened 2-x instances. I need prevent that the same user can't open multiple instances. But notice that the program can be opened multiple times by different users. Please forgive me my English. Thanks.
PS: I'm using Winforms and C#
You can create a mutex with the user's name.
bool b = true;
Mutex mutex = new Mutex(true, Environment.UserName.ToLowerInvariant() , out b);
if (!b) throw new InvalidOperationException("Another instance is running");
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With