Class SingleApplicationGuard
Represents a guard to prevent multiple instances of the application from running. To enable the guard, add an entry with key 'IsSingleInstanceApplication' and value 'true' to the 'app.config' file. When it is enabled, a second instance of the application will be closed and the first will be brought to the foreground.
[Export(typeof(IGuardApplicationStart))]
public class SingleApplicationGuard : IGuardApplicationStart
- Inheritance
-
SingleApplicationGuard
- Implements
- Inherited Members
Examples
To run LisRT as single instance application, set the IsSingleInstanceApplication value in the app.config file to true:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<appSettings>
<add key="IsSingleInstanceApplication" value="true"/>
</appSettings>
</configuration>
Constructors
SingleApplicationGuard()
Initializes a new instance of the SingleApplicationGuard class.
public SingleApplicationGuard()
Fields
AppSettingsKey
Application settings key to enable LisRT as single instance application.
public const string AppSettingsKey = "IsSingleInstanceApplication"
Field Value
Methods
CanStartApplication()
Gets a value indicating whether a new instance can be started.
public bool CanStartApplication()
Returns
- bool
True, if the application can start.
OnApplicationCannotStart()
Shows the already running instance, and exits the current instance.
public void OnApplicationCannotStart()