If you’re developing a winforms application with VB.NET you can set a checkbox in the designer to have a single instance application. This option is not available to C# developers but since language does not matter in the .NET space you can just use the same classes the VB.NET designer uses.
By subclassing WindowsFormsApplicationBase you can get the same behaviour. The class can be found in the Microsoft.VisualBasic.ApplicationServices namespace.
public class SingleInstanceManager : WindowsFormsApplicationBase { public SingleInstanceManager() { IsSingleInstance = true; EnableVisualStyles = true; ShutdownStyle = ShutdownMode.AfterMainFormCloses; } protected override bool OnStartup(StartupEventArgs e) { return true; } protected override void OnCreateMainForm() { base.OnCreateMainForm(); MainForm = new MainForm(); HideSplashScreen(); } protected override void OnStartupNextInstance(StartupNextInstanceEventArgs eventArgs) { base.OnStartupNextInstance(eventArgs); MainForm.Focus(); } protected override void OnCreateSplashScreen() { base.OnCreateSplashScreen(); SplashScreen = new SplashForm(); } }
Change your Program.cs to use this new class.
[STAThread] static void Main() { var manager = new SingleInstanceManager(); manager.Run(new string[]{}); }
Tags: winforms

will the recession become a depression…
Buy_without prescription…
teen girl 16 18.6 bmi…
Buy_generic drugs…
acne scar and pit lamp…
Buy_generic drugs…
synephrine hcl diet pills…
Buy_generic pills…
terry abbot…
Buy_generic drugs…
benicar hct and norvasc…
Buy_it now…
macon georgia drug court…
Buy_without prescription…
canadian@pharmacy.valtrex” rel=”nofollow”>……
Buygeneric meds…
indications@for.use.of.atrovent” rel=”nofollow”>……
Buygeneric meds…
long hairstyles…
I think this is one of the most significant information for me. And i am glad reading your article. But wanna remark on some general things, The site style is great, the articles is really nice : D. Good job, cheers…