Method AcquireAsync
- Namespace
- MVVrus.AspNetCore.ActiveSession
- Assembly
- MVVrus.AspNetCore.ActiveSession.dll
AcquireAsync(TimeSpan, CancellationToken)
Obtains an exclusive service accessor asynchronously.
Task<ILockedSessionService<TService>?> AcquireAsync(TimeSpan Timeout, CancellationToken Token)
Parameters
TimeoutTimeSpanTimeout for the process of obtaining an exclusive service accessor.
TokenCancellationTokenMay be used for cancellation of the process of obtaining an exclusive service accessor.
Returns
- Task<ILockedSessionService<TService>>
A task representing the process of obtaining an exclusive service accessor. The task result will be the exclusive service accessor obtained or null if the timeout expires.
Remarks
If a lock was put on a requested service by previous call of this method,
the the process of obtaining an exclusive accessor will wait until the lock is released
by disposing the previously obtained exclusive accessor or until the specified Timeout expires.
This process can also be canceled via Token cancellation token.
Exceptions
- ObjectDisposedException
Will be thrown when the associated active session is disposed during the accessor obtaining process.
- TaskCanceledException
Will be thrown when the accessor obtaining process is cancelled.