garethed / Q3

PoolQ the third
2 stars 7 forks source link

Make programme single-instance only. Fix #65 #66

Closed lx223 closed 8 years ago

lx223 commented 8 years ago

The change highlights look more confusing than the changes themselves.

What I have done is:

garethed commented 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

lx223 commented 8 years ago

Thanks for the comment and sry for the mess in the first commit. Hopefully, this looks better now.