Is GC.SuppressFinalize guaranteed?

后端 未结 5 879
清酒与你
清酒与你 2020-12-31 23:10

My observation in practice has been that GC.SuppressFinalize does not always suppress the call to the finalizer. It could be that the finalizer gets called nontheless. I won

5条回答
  •  一整个雨季
    2021-01-01 00:03

    I throw an InvalidOperationException in the finalizer which makes it easy to find types which haven't been disposed properly. When Dispose() is called where GC.SuppressFinalize is invoked, I never get an exception.

提交回复
热议问题