The OwnerReturn is used on return values of methods and properties to declare ownership of disposable objects.
sealed class
|
OwnerReturn
|
extends
|
Attribute
|
The following rules depict - based on the ownership status - when a disposable object must be disposed and when disposal must not be performed. Going by these rules will avoid situations where a resource is disposed although it is still being used and situations when a resource is never explicitly disposed, thus wasting system resources.
... [OwnerReturn] IDisposable MyObj(...) { ... } ...The caller takes ownership of the object that is returned by the method and becomes responsible for its disposal.
... [OwnerReturn] IDisposable MyObj { get { ... } } ...The caller takes ownership of the object that is returned by the property and becomes responsible for its disposal.
See also:
Owner