Closed lx223 closed 8 years ago
Thanks. This looks promising, but I don't think you're handling all the edge cases. See e.g. http://stackoverflow.com/questions/229565/what-is-a-good-pattern-for-using-a-global-mutex-in-c/229567 for a quite detailed example - in particular you're not cleaning up after your mutex or handling AbandonedMutexExceptions properly.
A couple of other ways this could be nicer:
i.e. OnStartup should look like;
if (AnotherInstanceIsRunning()) {
// shutdown
}
// (otherwise) do all the existing stuff
and all your new code should be in a new AnotherInstanceIsRunning method
Thanks for the comment and sry for the mess in the first commit. Hopefully, this looks better now.
The change highlights look more confusing than the changes themselves.
What I have done is: