G
Guest
Someone suggested that calling Control.CreateGraphics() is expensive and thus
it might be a good idea to cache the returned Graphics object. Is this true?
Back in the unmanaged world I remember something like there were only 5 DC's
to work with within your application so if objects attempted to cache their
DC's or if you had a leak your application would quickly freeze. I assume
the same sort of thing applies with the Graphics object unless it's a layer
above the DC. But if it's a layer above the DC I would not expect creating
one to be an expensive operation. Also, if it is expensive to create a
Graphics object and there is no harm in caching one I would have expected the
underlying framework (Windows / .NET) to have done the caching for me instead
of having each user of the framework implement their own caching mechanism.
(Also posted on the .NET drawing newsgroup)
it might be a good idea to cache the returned Graphics object. Is this true?
Back in the unmanaged world I remember something like there were only 5 DC's
to work with within your application so if objects attempted to cache their
DC's or if you had a leak your application would quickly freeze. I assume
the same sort of thing applies with the Graphics object unless it's a layer
above the DC. But if it's a layer above the DC I would not expect creating
one to be an expensive operation. Also, if it is expensive to create a
Graphics object and there is no harm in caching one I would have expected the
underlying framework (Windows / .NET) to have done the caching for me instead
of having each user of the framework implement their own caching mechanism.
(Also posted on the .NET drawing newsgroup)