2021年4月22日星期四

Why scoped service disposed earlier than transient service in dotnet?

Doc Link: dotnet DI link

I have done the Tutorial step by step, but I fond a problem: Why scoped service disposed earlier than transient service in dotnet?

Scope 1...  ScopedDisposable.Dispose()  TransientDisposable.Dispose()    Scope 2...  ScopedDisposable.Dispose()  TransientDisposable.Dispose()  

Addtional, I have found another discription on preceding DOC links. At section "IDisposable guidance for Transient and shared instances"

There is a more confused description:

The instance should be disposed before the scope ends.

https://stackoverflow.com/questions/67213913/why-scoped-service-disposed-earlier-than-transient-service-in-dotnet April 22, 2021 at 09:07PM

没有评论:

发表评论