Interface ISessionServiceLock<TService>
- Namespace
- MVVrus.AspNetCore.ActiveSession
- Assembly
- MVVrus.AspNetCore.ActiveSession.dll
This generic interface is intended to obtain an exclusive access to a scoped service instance within the current active session's service scope (if any).
public interface ISessionServiceLock<TService>
Type Parameters
TService
Type of the service to which the exclusive access to be obtained
Remarks
This interface is registered as a scoped service in the application's DI container as a part of registering the ActivesSession infrastracture services. It is designed to be obtained from a request's scope.
If no active session for a request is available, the process of obtaining an exclusive accessor for a service performed by this ISessionServiceLock service falls back to the request's scope DI container. This is done for compatibility reason: a service accessor obtained this way may be used by a request handler irrespective of existence of an active session for the request. Because scoped service instances from request DI containers are never shared between requests, the service accessor ILockedSessionService<TService> obtained from the request's scope DI container doesn't really represent any lock, so many of such accessors for different requests may be obtained simultaneously.
Methods
- AcquireAsync(TimeSpan, CancellationToken)
Obtains an exclusive service accessor asynchronously.