I am writing a C# console app. It’s going to run as a scheduled task.
I want my EXE to exit quickly if it finds that another process is still running from the previous schedule task execution.
I can’t seem to find the way to let my app detect the active processes, and so know whether it’s already running or not.
Thanks for any ideas.
Peter
One very common technique is to create a mutex when your process starts. If you cannot create the mutex it means there is another instance running.
This is the sample from Nathan’s Link: