When a certain criteria is reached my application runs Application.Restart to restart the application. This leaves a process hanging so that when the application comes back up it complains that it is already running (I have code to check that only one instance of the application is allowed).
This process can be eliminated by calling Environment.Exit but this conflicts with Application.Restart. When Restart is called, and then Environment.Exit, the restart is aborted and the application just quits without trying to restart.
How can I get around this?
A bit more info:
My main class instantiates a subclass. This subclass calls Application.Restart if certain criteria are met. This causes .Net to call the FormClosed event on the main class. This event calls Environment.Exit to make sure all processes are closed when the user quits the application, which causes the restart to be aborted.