Class MainDomSemaphoreLock
Uses a system-wide Semaphore and EventWaitHandle to synchronize the current AppDomain
Inheritance
Namespace: Umbraco.Cms.Core.Runtime
Assembly: Umbraco.Core.dll
Syntax
public class MainDomSemaphoreLock : IMainDomLock
Constructors
View SourceMainDomSemaphoreLock(ILogger<MainDomSemaphoreLock>, IHostingEnvironment)
Initializes a new instance of the MainDomSemaphoreLock class.
Declaration
public MainDomSemaphoreLock(ILogger<MainDomSemaphoreLock> logger, IHostingEnvironment hostingEnvironment)
Parameters
| Type | Name | Description |
|---|---|---|
| ILogger<MainDomSemaphoreLock> | logger | The logger instance. |
| IHostingEnvironment | hostingEnvironment | The hosting environment for generating lock names. |
Exceptions
| Type | Condition |
|---|---|
| PlatformNotSupportedException | Thrown when not running on Windows. |
Methods
View SourceAcquireLockAsync(int)
Acquires an application-wide distributed lock
Declaration
public Task<bool> AcquireLockAsync(int millisecondsTimeout)
Parameters
| Type | Name | Description |
|---|---|---|
| int | millisecondsTimeout |
Returns
| Type | Description |
|---|---|
| Task<bool> | An awaitable boolean value which will be false if the elapsed millsecondsTimeout value is exceeded |
Dispose()
Declaration
public void Dispose()
Dispose(bool)
Releases the unmanaged resources used by the MainDomSemaphoreLock and optionally releases the managed resources.
Declaration
protected virtual void Dispose(bool disposing)
Parameters
| Type | Name | Description |
|---|---|---|
| bool | disposing |
|
ListenAsync()
Wait on a background thread to receive a signal from another AppDomain
Declaration
public Task ListenAsync()
Returns
| Type | Description |
|---|---|
| Task |
Remarks
WaitOneAsync (extension method) will wait for a signal without blocking the main thread; the waiting is done on a background thread.