-
Notifications
You must be signed in to change notification settings - Fork 13
ITransient
The concept of an ITransient is something that exists for a period of time, then is deleted.
This idea was once used extensively in programming, especially in C++, where we had clear scoping rules and when the destructor would always be called when an object instance went out of scope.
In .Net-world, this mechanism cannot used because of the garbage collector. But this is a shame, as there are some vary valuable flow control patterns that are then missed.
ITransient adds the ability to control the lifetime of an object in .Net.
This is entirely logical, as the GC still controls resource usage, object lifetime management and resource allocation - but we can take back flow-control logic and determinism by using ITransient.
An ITransient can be deleted by calling its Delete() method, which also fires an event. The term 'deleted' here is logical and is not related to the .NET garbage collector. We can chain ITransient deletion of instance A and B by using A.DeleteAfter(B).