How to dispose objects having asynchronous methods called?

后端 未结 7 2147
再見小時候
再見小時候 2020-12-18 21:34

I have this object PreloadClient which implements IDisposable, I want to dispose it, but after the asynchronous methods finish their call... which

7条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-18 22:24

    Asynchronous waits and deterministic disposal don't mix very well. If you can find a way of splitting the code such that the disposable stuff goes in one class and the events go in another, that would make everything simpler.

提交回复
热议问题