Safe to call managed resource from Finalizer? (if i check null)
问题 Is it not safe to call: component.Dispose(); (if i check null) from the Finalizer if i alter the code to this: ~MyResource() { Dispose(); } public void Dispose() { // Check to see if Dispose has already been called. if(!this.disposed) { if(component != null) component.Dispose(); // !!! // CloseHandle(handle); handle = IntPtr.Zero; disposed = true; } GC.SuppressFinalize(this); } I know this works - but is it safe? (from the example below?) Code example: (before alter code) http://msdn