The Correct Way

Dec 1, 2009 at 10:13 PM

Umm yeah, Read, Read, Read. Try Using a Mutex in you Applications Main() Method. All Done!

This project is Useless, Sorry.

Dec 1, 2009 at 11:39 PM
Edited Mar 8, 2011 at 4:45 PM

Yes, read, read, read and learn. Then post a comment, an article, or whatever is worth something. This is the way I do things: before writing something I tend to achieve a good overview of the problem, then I try to decide (depending on my knowledge, tastes and experience) what is good or bad about the the various approaches, finally I elaborate my own solution or accept someone else's one.

Your post states clearly that you got bored in the overview, and did not even look at the code... If you had done that, you would have discovered that this project uses a mutex in the main method, since it acquires it during the Application.Run (which is called in the Main method, as you know), moreover it takes into account race conditions between multiple instances, inter-process communication (i.e. passing startup parameters to an existing application instances), host-level or user-level single instance restriction, and finally allows for a neat way to achieve single instance applications using WPF, without the need to define a Main method or breaking the Visual Studio WPF Designer functionality.

This project, as stated in the project overview, is a possible and (in my opinion) elegant solution to a common problem.

For the sake of clarity, I am not disappointed by the last comment about the unusefullness of the project (you are free to think and write that as much as you want, it is your opinion), but I don't like the fact that you created a post with the title 'The Correct Way', pointing to a StackOverflow answer that:

  1.  Is not directly related to WPF and does not take into account all the problems related to this context (maintaining the App.xaml file and its resources, making it as simple as possible, compatibility with designer...)
  2. Does not take into account the single instance restriction (even if it is possible to find more information reading through the comments)
  3. Does not take into account passing next instances parameters to the main instance

In other words, you wrote a comment without understanding the project, and just pointing out some random resource, claiming it to be the solution of a problem you did not understand.