AsyncScopedLifestyleBeginScope Method

Simple Injector
Begins a new scope for the given container. Services, registered using the AsyncScopedLifestyle are cached during the lifetime of that scope. The scope should be disposed explicitly.

Namespace:  SimpleInjector.Lifestyles
Assembly:  SimpleInjector (in SimpleInjector.dll) Version: 5.3.0
Syntax

public static Scope BeginScope(
	Container container
)

Parameters

container
Type: SimpleInjectorContainer
The container.

Return Value

Type: Scope
A new Scope instance.
Exceptions

ExceptionCondition
ArgumentNullException Thrown when the container is a null reference.
Examples

C#
using (AsyncScopedLifestyle.BeginScope())
{
    var handler = (IRequestHandler)container.GetInstance(handlerType);

    handler.Handle(request);
}
See Also

Reference