Purpose of Dispose calling Dispose(IsDisposing) pattern in C#?

后端 未结 4 1536
清歌不尽
清歌不尽 2020-12-16 04:18

Here is code from MSDN. I don\'t understand why the work isn\'t just done in the regular Dispose() method here. What is the purpose of having the Dispose(bool) method? Wh

4条回答
  •  长情又很酷
    2020-12-16 05:02

    This is to allow the finalizer to work property, as well as to allow subclasses which derive from your class to dispose properly.

    If you want more detailed info, I wrote a 5 part blog series on IDisposable, and covered the subclassing issue in detail in the Subclass from an IDisposable Class article.

提交回复
热议问题