Should implementations of IDisposable make Dispose() safe to call multiple times? Or the opposite? What approach to most .NET Framework classes take?
Specifically, is it safe to call System.Data.Linq.DataContext.Dispose() multiple times?
The reason I ask is because I am wondering if this extra protection is necessary:
public override void Dispose(bool disposing)
{
// Extra protection...
if (this.obj != null)
{
this.obj.Dispose();
this.obj = null;
}
// Versus simply...
this.obj.Dispose();
base.Dispose(disposing);
}
when disposing IDisposable members of a class, or whether I should just call this.obj.Dispose() without concern for whether it has been previously called.