The OwnerThis is used on instance methods to declare ownership of disposable objects.
sealed class
|
OwnerThis
|
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.
... [OwnerThis] void MyObj(...) { ... } ... [OwnerThis] void MyObj(this IDisposable obj, ...) { ... } ...The instance method takes ownership of the object that is (implicitly passed) to it as
this
,
so
the
storage
container
from
which
the
value
of
this
has
originated
is
no
longer
responsible
for
disposal.
See also:
Owner