Class Mutex
- Namespace
- Temporalio.Workflows
- Assembly
- Temporalio.dll
public class Mutex
- Inheritance
-
Mutex
- Inherited Members
Methods
ReleaseMutex()
Release the mutex for use by another waiter.
public void ReleaseMutex()
Exceptions
- InvalidOperationException
Thrown if the mutex was not waited on successsfully.
WaitOneAsync(int, CancellationToken?)
Wait for the mutex to become available or timeout to be reached. If the task returns true, users must call ReleaseMutex() to properly release the mutex when done.
public Task<bool> WaitOneAsync(int millisecondsTimeout, CancellationToken? cancellationToken = null)
Parameters
millisecondsTimeout
intMilliseconds until timeout. If this is 0, this is a non-blocking task that will return immediately. If this value is -1 (i.e. Infinite), there is no timeout and the result will always be true on success (at which point you might as well use WaitOneAsync(CancellationToken?)). Otherwise a timer is started for the timeout and canceled if the wait succeeds.
cancellationToken
CancellationToken?Cancellation token that can interrupt this wait. If unset, this defaults to CancellationToken. Upon cancel, awaiting the resulting task will throw a TaskCanceledException exception.
Returns
- Task<bool>
A Task representing the result of the asynchronous operation. The task is true if the wait succeeded and false if it timed out. This task is canceled if the cancellation token is.
WaitOneAsync(CancellationToken?)
Wait for the mutex to become available. If the task succeeds, users must call ReleaseMutex() to properly release the mutex when done.
public Task WaitOneAsync(CancellationToken? cancellationToken = null)
Parameters
cancellationToken
CancellationToken?Cancellation token that can interrupt this wait. If unset, this defaults to CancellationToken. Upon cancel, awaiting the resulting task will throw a TaskCanceledException exception.
Returns
- Task
A Task representing the result of the asynchronous operation. This task is canceled if the cancellation token is.
WaitOneAsync(TimeSpan, CancellationToken?)
Wait for the mutex to become available or timeout to be reached. If the task returns true, users must call ReleaseMutex() to properly release the mutex when done.
public Task<bool> WaitOneAsync(TimeSpan timeout, CancellationToken? cancellationToken = null)
Parameters
timeout
TimeSpanTimeSpan until timeout. If this is Zero, this is a non-blocking task that will return immediately. If this value is -1ms (i.e. InfiniteTimeSpan), there is no timeout and the result will always be true on success (at which point you might as well use WaitOneAsync(CancellationToken?)). Otherwise a timer is started for the timeout and canceled if the wait succeeds.
cancellationToken
CancellationToken?Cancellation token that can interrupt this wait. If unset, this defaults to CancellationToken. Upon cancel, awaiting the resulting task will throw a TaskCanceledException exception.