ScopedLifestyleWhenScopeEnds Method

Simple Injector
Allows registering an action delegate that will be called when the scope ends, but before the scope disposes any instances.

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

public void WhenScopeEnds(
	Container container,
	Action action
)

Parameters

container
Type: SimpleInjectorContainer
The Container instance.
action
Type: SystemAction
The delegate to run when the scope ends.
Exceptions

ExceptionCondition
ArgumentNullExceptionThrown when one of the arguments is a null reference.
InvalidOperationExceptionWill be thrown when there is currently no active scope for the supplied container.
Remarks

During the call to Dispose all registered Action delegates are processed in the order of registration. Do note that registered actions are not guaranteed to run. In case an exception is thrown during the call to Dispose, the Scope will stop running any actions that might not have been invoked at that point. Instances that are registered for disposal using RegisterForDisposal(Container, IDisposable) on the other hand, are guaranteed to be disposed. Note that registered actions won't be invoked during a call to Verify.
See Also

Reference