Advertisment

How to restrict a program to a single instance?

author-image
CIOL Bureau
Updated On
New Update

In the program's Main method, call ProcessUtils.ThisProcessIsAlreadyRunning() to determine if another instance of the program is already running. ThisProcessIsAlreadyRunning attempts to create a Mutex object with the same name as the program (Application.ProductName). If it fails, the Mutex object already exists (and was created by another instance of the same program).

If another instance of the program is already running, that instance is made visible and input focus is set to it. Otherwise a new instance of the program is launched.

Click here for more...!

tech-news