Which scope must be used if we want the instance collected by the GC to be disposed properly?

StackOverflow https://stackoverflow.com/questions/15465323

  •  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?

War es hilfreich?

Lösung

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.

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 Disposed 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
scroll top