KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I use a default IDisposable implementation template (pattern) for my code. snippet: public void Dispose() { Dispose(true); GC.SuppressFinalize(this); } protected virtual void Dispose(bool isDisposing) { if (!this.disposed) { if (isDisposing) { //cleanup managed resources } //cleanup unmanaged resources this.disposed = true; } } My question: why is the call "GC.SuppressFinalize(this)" in the Dispose public method? I would place "GC.SuppressFinalize(this)" in the "if (isDisposing)" section of the protected method, after disposing managed resources. Like this: protected virtual void Dispose(bool isDisposing) { if (!this.disposed) { if (isDisposing) { //cleanup managed resources GC.SuppressFinalize(this); } //cleanup unmanaged resources this.disposed = true; } }
Tags (comma-separated)
Save Edits
Cancel