Resolved Where to dispose unmanaged objects

aaaron

Well-known member
Joined
Jan 23, 2011
Messages
216
Programming Experience
10+
In a user control where is the best place to dispose unmanaged objects?
 
Solution
UserControl implements IDisposable through base Component class and overrides Dispose(disposing) in generated Designer code.

The generated code is before the "do not modify" message, so you could add a call here to your own cleanup method in user code file. In IDisposable pattern cleanup of unmanaged resources should happen after the "if disposing ... end if" block, in other words always, whether disposing or finalizing.
UserControl implements IDisposable through base Component class and overrides Dispose(disposing) in generated Designer code.

The generated code is before the "do not modify" message, so you could add a call here to your own cleanup method in user code file. In IDisposable pattern cleanup of unmanaged resources should happen after the "if disposing ... end if" block, in other words always, whether disposing or finalizing.
 
Solution
Yes.
 
Back
Top