Pretasoc / SingleInstanceManager

An c# wrapper for single instance applications

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

SingleInstanceManager

A c# wrapper for single instance applications

This project is inspired by this solution for single instance applications, extended by a mechanism to share the command line parameters of the second instance. This is done using a system wide named pipe.

Usage

public static int Main(string[] args){
    // submit an optional guid. If no parameter is given the entry assembly name is used.
    var instanceManager = SingleInstanceManager.CreateManager("{GUID}");
        if(instanceManager.RunApplication(args)){
            // Register an event handler for second instances
            instanceManager.SecondInstanceStarted + = OnSecondInstanceStarted;
            // perform other bootstrap operations
            // ...
            // Close the manager, so other instances can start in a valid state       
            instanceManager.Shutdown();
        }
        // perform exit logic
    }

About

An c# wrapper for single instance applications


Languages

Language:C# 100.0%