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

Pergunta

Must InParentScope be used if one wants an instance collected by GC to be Disposed properly ? If not which Scope should be used instead?

Foi útil?

Solução

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.

Outras dicas

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.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top