Created
November 1, 2017 18:30
-
-
Save ridomin/5ac09e0c2598f936170f4d58f486d85c to your computer and use it in GitHub Desktop.
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
namespace Rido.SingleInstance | |
{ | |
public class SingleInstanceManager<T> : Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase | |
where T: System.Windows.Application, new() | |
{ | |
T app; | |
public SingleInstanceManager() | |
{ | |
base.IsSingleInstance = true; | |
} | |
protected override bool OnStartup(Microsoft.VisualBasic.ApplicationServices.StartupEventArgs e) | |
{ | |
app = new T(); | |
app.Run(); | |
return false; | |
} | |
protected override void OnStartupNextInstance(Microsoft.VisualBasic.ApplicationServices.StartupNextInstanceEventArgs e) | |
{ | |
app.MainWindow.Activate(); | |
} | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment