Question on Graphics Disposal
Question
Do I need to call Dispose() on a Graphics object obtained through PaintEventArgs in an OnPaint event?
Solution
No, the calling layer (the one who actually created the graphics object) is in charge of that. Also think about it, when you have other callees on the chain, you will dispose the object and they won't be able to use it.
OTHER TIPS
In general, you should not dispose of Graphic objects which you receive as method parameters. But you should dispos of Graphics objects that you've created yourself (for example using the CreateGraphics
method).
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow