Long overdue (for me) question about disposing managed objects in .Net, VB.Net, C#

Posted by Jules on Stack Overflow See other posts from Stack Overflow or by Jules
Published on 2010-03-30T20:57:07Z Indexed on 2010/03/30 21:03 UTC
Read the original article Hit count: 477

Filed under:
|
|
|

I can't believe I'm still confused about this but, any way, lets finally nail it:

I have a class that overrides OnPaint to do some drawing. To speed things up, I create the pens, brushes etc before hand, in the construtor, so that OnPaint does not need to keep creating and disposing them.

Now, I make sure that I always dispose of such objects, but I have the feeling I don't need to because, despite the fact they implement IDisposable, they're managed objects.

Is this correct?

© Stack Overflow or respective owner

Related posts about .NET

Related posts about idisposable