If your question is not covered by https://github.com/ninject/ninject/wiki/Object-Scopes, I'll be happy to make any changes needed based on any follow-ups you have.
Which scope must be used if we want the instance collected by the GC to be disposed properly?
-
24-03-2022 - |
Frage
Must InParentScope
be used if one wants an instance collected by GC to be Disposed properly ? If not which Scope should be used instead?
Lösung
Andere Tipps
Objects any scope except InTransientScope()
are disposed when the lifetime of the scope ends. There is no correct one as the scope defines how long an object lives and this depends on the concrete situation.
An object InParentScope()
is Dispose
d when the object it is injected into is either garbage collected or when it is deactivated by Ninject because its own scope has ended.
Note that if the Scope of the Parent is InTransientScope()
, the object will not be tracked, so use it with care.
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow