• Articles
  • Api Documentation
Show / Hide Table of Contents
  • Dapplo.Addons
    • IAction
    • IApplicationBootstrapper
    • IAsyncShutdownAction
    • IAsyncStartupAction
    • IBootstrapper
    • IDependencyProvider
    • IMefServiceLocator
    • IModule
    • IServiceExporter
    • IServiceRepository
    • IShutdownAction
    • IShutdownMetadata
    • IShutdownModule
    • IStartupAction
    • IStartupMetadata
    • IStartupModule
    • ModuleAttribute
    • ShutdownActionAttribute
    • StartupActionAttribute
    • StartupException
  • Dapplo.Addons.Bootstrapper
    • ApplicationBootstrapper
    • CompositionBootstrapper
    • ResourceMutex
    • StartupShutdownBootstrapper
  • Dapplo.Addons.Bootstrapper.Internal
    • CompressionTypes
    • StreamExtensions
  • Dapplo.Addons.Bootstrapper.Resolving
    • AssemblyResolver
    • EmbeddedResources
    • FileLocations
    • FileTools

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 Source

IsLocked

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 Source

Create(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
| Improve this Doc View Source

Dispose()

Dispose the application mutex

Declaration
public void Dispose()
| Improve this Doc View Source

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

  • Improve this Doc
  • View Source
Back to top Copyright © 2017 Dapplo