Class SingleInstanceActivator
A single-instance application activator.
public class SingleInstanceActivator : IDisposable
- Inheritance
-
SingleInstanceActivator
- Implements
- Inherited Members
Constructors
SingleInstanceActivator(string)
Initializes a new instance of the SingleInstanceActivator class.
public SingleInstanceActivator(string applicationIdentifier)
Parameters
applicationIdentifier
stringA unique identifier for this application, which is used to find and activate another running instance. This is typically a GUID.
Exceptions
- ArgumentNullException
applicationIdentifier
is null.
Properties
IsFirstInstance
Gets whether this is the first instance of this application.
public bool IsFirstInstance { get; }
Property Value
Methods
ActivateFirstInstance()
Sends a signal to the first running application instance, requesting that it activate itself.
public void ActivateFirstInstance()
Dispose()
Closes and releases all resources used by the object.
public void Dispose()
Dispose(bool)
Closes and releases all resources used by the SingleInstanceActivator.
protected virtual void Dispose(bool disposing)
Parameters
Remarks
Derived classes should override this when they have any resources that should be disposed.
OnInstanceActivationRequested()
Called when instance activation is requested from another starting instance. This will be called from a background thread.
protected virtual void OnInstanceActivationRequested()
Remarks
The default behavior raises InstanceActivationRequested, and if it is not canceled, activates this instance.
StartActivator()
Starts the single-instance activator, which watches for signals from other started application instances, activating this instance as they are received.
public void StartActivator()
Exceptions
- InvalidOperationException
This is not the first instance of this application.
Events
InstanceActivationRequested
Raised when instance activation is requested from another starting instance. This will be raised from a background thread.
public event EventHandler<CancelEventArgs> InstanceActivationRequested