How and when to dispose my objects?

前端 未结 1 867
感动是毒
感动是毒 2021-01-27 04:06

In my backend service I use unit of work pattern. I was wondering if I\'m missing something related to disposing objects.

First, this is the code I have so far, which w

相关标签:
1条回答
  • 2021-01-27 04:44

    Whenever you use something that implements IDisposable you should Dispose it as soon as you don't need it any more. If you use it as a field in a class, implement IDisposable in that class and iterate this process.

    PS: If you turn on Code Analysis like this: enter image description here

    you will get some warnings pointing you to this for free :D

    0 讨论(0)
提交回复
热议问题