Class ResourceMutex
This protects your resources or application from running more than once Simplifies the usage of the Mutex class, as described here: https://msdn.microsoft.com/en-us/library/System.Threading.Mutex.aspx
Inheritance
System.Object
ResourceMutex
Namespace:Dapplo.Addons.Bootstrapper
Assembly:Dapplo.Addons.Bootstrapper.dll
Syntax
public sealed class ResourceMutex : IDisposable
Properties
| Improve this Doc View SourceIsLocked
Test if the Mutex was created and locked.
Declaration
public bool IsLocked { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean |
Methods
| Improve this Doc View SourceCreate(String, String, Boolean)
Create a ResourceMutex for the specified mutex id and resource-name
Declaration
public static ResourceMutex Create(string mutexId, string resourceName = null, bool global = false)
Parameters
Type | Name | Description |
---|---|---|
System.String | mutexId | ID of the mutex, preferably a Guid as string |
System.String | resourceName | Name of the resource to lock, e.g your application name, usefull for logs |
System.Boolean | global | true to have a global mutex see: https://msdn.microsoft.com/en-us/library/bwe34f1k.aspx |
Returns
Type | Description |
---|---|
ResourceMutex |
Dispose()
Dispose the application mutex
Declaration
public void Dispose()
Lock()
This tries to get the Mutex, which takes care of having multiple instances running
Declaration
public bool Lock()
Returns
Type | Description |
---|---|
System.Boolean | true if it worked, false if another instance is already running or something went wrong |