Skip to content

SJC08/SingletonApp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

This library allows you to create single instance applications.

Use Asjc.* instead of AS.* and AsUtils.*!

Getting started

Call the SingletonApp.Check method at an appropriate place. It will return a bool indicating whether the application is a new instance.

// WPF
protected override void OnStartup(StartupEventArgs e)
{
    base.OnStartup(e);

    if (!SingletonApp.Check())
        Shutdown();
}

Don't forget to call the SingletonApp.Cleanup method when the application is closed!

Attention

Do not call the SingletonApp.Check method repeatedly. Use SingletonApp.IsNew instead, unless you are fully aware of what you are doing.

bool result1 = SingletonApp.Check(); // True
bool result2 = SingletonApp.IsNew; // True
bool result3 = SingletonApp.Check(); // False
bool result4 = SingletonApp.IsNew; // False

About

Ensure only one instance of the application is running.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages