I'm currently writing a fairly complex paint method for a user control, involving a fair amount of drawing code. I know that all GDI+ resources need to be properly disposed so I wrap each of those in a using
block.
But when I noticed that I used three using
blocks for three different SolidBrushes
I wondered whether I couldn't just re-use them. Create a SolidBrush
, draw with it, assign a different color, draw something else, etc. And put a Dispose()
at the end.
Is such a thing advisable or am I thinking too hard here? I don't particularly like too many using
blocks nested in each other as well. While a nice pattern it hinders readability at times.