How to allow only one user to run my program in C #, but also allow multiple instances?

The situation is that I want to allow users to open multiple instances of the program, but I do not want more than one user connected to the user to use the program immediately. So, for example, if the program is installed on the server, and several users can use the remote desktop on the server, I want one user to be able to run the program, but still be able to run multiple instances. I studied the use of the mutex, but from what I found, the mutex allowed only one instance of the program. Is this possible with C #?

+3
source share
4 answers

I would use a named Mutex. Inside your protection, keep a record of the currently logged in user. If it exists, and it is not the current user, then exit - otherwise, note that the current user is starting the application.

+2
source

This is usually handled through a separate application that acts as a license manager. You may have a service that maintains licenses and monitors current usage, and when you connect your application to the manager at startup. The manager can check the credentials and answer whether to allow the application to run or not, depending on any criteria, including only 1 user (with multiple copies), up to N users, etc.

Windows Communication Foundation / .

+3

. , , , . , .

: , , . , , ... - , . x . , , . , . , ... , .

0

Use named mutex. The Mutex name will be MyMutex_ [username] Thus, you will have a separate Mutex single for each user.

0
source

Source: https://habr.com/ru/post/1770815/


All Articles