If I have a Dispose method, should I implement IDisposable?

I have a class containing a method Dispose. In this method, I interrupt the thread. Do I need to implement an interface IDisposable?

+4
source share
1 answer

If you implement an interface IDisposable, then your class object can be used by using a block that automatically invokes the method Disposeimplicitly.

From answer from JaredPar

There are only 2 reasons to implement IDisposable for type

  • The type contains its own resources that should be freed when the type is no longer used.
  • The type contains fields of type IDisposable

- IDisposable , ?

+1

All Articles