I have an application that I restart at 2 in the morning every morning using
Application.Restart();
the problem is that the inspection after a couple of weeks shows that about 6 copies are working.
I tried to limit the number of instances using
bool IsOwned;
Mutex m = new Mutex(true, Name, out IsOwned);
if (!IsOwned)
Environment.Exit(0);
But that did not work, because for some reason the recently stopped instance was still visible ... or at least this is my interpretation, and as a result the application did not restart.
Where am I wrong?
source
share