Adds the disposable to the list of items that will get disposed when the
scope ends.
Namespace: SimpleInjector
Assembly: SimpleInjector (in SimpleInjector.dll) Version: 5.3.0
Syntax
Parameters
- disposable
- Type: SystemIDisposable
The instance that should be disposed when the scope ends.
Exceptions
Exception | Condition |
---|---|
ArgumentNullException | Thrown when one of the arguments is a null reference. |
ObjectDisposedException | Thrown when the scope has been disposed. |
Remarks
Instances that are registered for disposal, will be disposed in opposite order of registration and they are guaranteed to be disposed when Dispose is called (even when exceptions are thrown). This mimics the behavior of the C# and VB
using
finally
Thread safety: Calls to this method are thread safe.
See Also