Usually, when I override the OnPaint method, I create pens and brushes in it, etc., and then delete them.
I also read somewhere that instead of recreating these pens and brushes, etc., create them once as static members, and then delete them once when the form is closed, etc.
Is this the best practice?
Is there a better way to do this?
I can assume that since OnPaint is called 1000s (?) Times, this would create more work for the GC compared to creating them only once.
source
share