My current project presented a unique challenge. I have a need to:
- allow only one instance of the application to run at each workstation,
- notify the user that an instance is already running if a second instance is started, and
- be able to programmatically restart the application.
Thankfully, Microsoft has provided the SingleInstance.cs to serve these needs. Following this article on CodeProject.com was a great start. The author Arik Poznanski did an excellent job explaining the steps necessary to implement the first two requirements. I combined his techniques with information found in this article on StackOverflow.com to fully satisfy all three requirements – an application that will only allow one instance, that will notify the user that an instance is already running, and that can easily be restarted programmatically. Continue reading