Tuesday, August 14, 2012

WPF Single instance application, Now a piece of cake,

I was thinking of making a single instance application, and in WPF, googled for a minute and found out this,

WPF application Single Instance in one line of code for usage

http://wpfsingleinstance.codeplex.com/

features

Usage: WpfSingleInstance.Make(); or WpfSingleInstance.Make(SingleInstanceModes.ForEveryUser);
1. Add only a line of code (above) in the App.xaml.cs or in the main window.
2. Add a small static class in project (and a dummy enum SingleInstanceModes).
No additional inheritance in App class.
No App.xalm deleting.
No so redundant WCF and Remoting.
It works by the EventWaitHandle. Look in code, it's so simply.

I like it, hope all will like it.

Included a single cs file in my project named “WpfSingleInstance.cs”

then added the following line

public partial class App : Application
{
protected override void OnStartup(StartupEventArgs e)
{
WpfSingleInstance.Make();

base.OnStartup(e);
}
}


Man!! couldn’t get better than this, thanks to the contributor,

Until next time. Bye bye

No comments:

Post a Comment