I am refactoring a program right now. Trying to prevent memory leaks I was looking for objects to enclose in using
blocks when I found a TaskDefinition
object (class found in Microsoft.Win32.TaskScheduler
) that Dispose
was not called on. When I tried to enclose it VisualStudio told me that this class does not implement IDisosable
. Looking at the class this is certainly true:
namespace Microsoft.Win32.TaskScheduler
{
// Summary:
// Defines all the components of a task, such as the task settings, triggers,
// actions, and registration information.
public sealed class TaskDefinition
{
...
// Summary:
// Releases all resources used by this class.
public void Dispose();
}
}
So why would you implement a Dispose
method but not implement the IDisposable
interface? Are there any drawbacks from implementing the interface?
Thank you for helping me to understand this.