I use this method that I developed myself.
I use it in many applications, since it integrates seamlessly with the WPF environment, and allows for inter-process communication (notification of next instances startup). If next instances have to close (single instance application), you just need to handle the Started event, checking if the the instance is not the first one, and shutdown the next application.
With this approach, you just need to use an Application-derived object (just changing the App.xaml and App.cs), without the need of defining the Main method explicitly.
Depending on your needs, you can decide to integrate the next-instance check inside the Bootstrapper startup, or before... it just depends on this question: do I need to configure a bootstrapper when the next application has to close? Personally, I prefer to let the bootstrapper be configured, so that I can log next instances and eventually handle/report unexpected exceptions in the same way as the main application. But it is just a personal choice.
I am considering creating a NuGet package for the project, and integrate a Caliburn.Micro based sample.
I use it in many applications, since it integrates seamlessly with the WPF environment, and allows for inter-process communication (notification of next instances startup). If next instances have to close (single instance application), you just need to handle the Started event, checking if the the instance is not the first one, and shutdown the next application.
With this approach, you just need to use an Application-derived object (just changing the App.xaml and App.cs), without the need of defining the Main method explicitly.
Depending on your needs, you can decide to integrate the next-instance check inside the Bootstrapper startup, or before... it just depends on this question: do I need to configure a bootstrapper when the next application has to close? Personally, I prefer to let the bootstrapper be configured, so that I can log next instances and eventually handle/report unexpected exceptions in the same way as the main application. But it is just a personal choice.
I am considering creating a NuGet package for the project, and integrate a Caliburn.Micro based sample.