If you have a class that has a field which inherits from IDisposable you should probably go ahead and make your class inherit from IDisposable. A class holding a System.Timers.Timer is an example given on page 493 of C# 4.0 in a Nutshell: The Definitive Reference by Joseph Albahari and Ben Albahari. In the example the class is given a Dispose method which would run at the end of a using block. The Dispose method on the class calls the Dispose method on the timer. This seems a good pattern.
No comments:
Post a Comment