Created
January 11, 2012 19:47
-
-
Save dbuksbaum/1596414 to your computer and use it in GitHub Desktop.
SingleInstanceManager
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Linq; | |
using System.Windows; | |
using Microsoft.VisualBasic.ApplicationServices; | |
using StartupEventArgs = Microsoft.VisualBasic.ApplicationServices.StartupEventArgs; | |
namespace Utility | |
{ | |
public class SingleInstanceManager : WindowsFormsApplicationBase | |
{ | |
[STAThread] | |
public static void Main(string[] args) | |
{ | |
var manager = new SingleInstanceManager(); | |
manager.Run(args); | |
} | |
public SingleInstanceManager() | |
{ | |
IsSingleInstance = true; | |
} | |
protected override bool OnStartup(StartupEventArgs eventArgs) | |
{ | |
Loader.Start(); | |
return false; | |
} | |
protected override void OnStartupNextInstance(StartupNextInstanceEventArgs eventArgs) | |
{ | |
base.OnStartupNextInstance(eventArgs); | |
((App)Application.Current).HandleArguments(eventArgs.CommandLine.ToArray()); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment