Prevent multiple instances in server same username

前端 未结 2 1901
误落风尘
误落风尘 2021-01-18 22:13

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 ha

2条回答
  •  情歌与酒
    2021-01-18 22:56

    The recommended way to see if another instance of your application is already running is to use a Mutex. See here for example.

    Since you want to allow multiple instances of the application to run if different users run them, simply add the current user name to the mutex's name. For example, call the Mutex "MyApp"+Environment.UserName

提交回复
热议问题