I have a number of classes which have private member variables that implement IDisposable (timers, brushes, etc). Do I need to do anything to ensure these variables are cleaned
You have some good information and some misinformation in your understanding.
The long and short of it is that you need to Dispose()
anything that implements IDisposable
.
Being as these are private member variables of your class, and if these are supposed to be available for the lifetime of instances of that class, your class should also implement IDisposable
and Dispose()
of those types in its own Dispose()
method.
If those private member variables have a limited lifetime (i.e. only within one method), just wrap them in a using
block.