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

문제

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

도움이 되었습니까?

해결책

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.

다른 팁

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top