Does it make sense to Freeze a Geometry/Brush even if I only use it once?

It depends. Freeze will make your code faster, since WPF will not care about lot of stuff any more, as freezed object cannot be modified. So if your code uses some objects frequently and it's performance issue, then you should try freezing it.

On the other hand - if code is not giving you any performance problems at all, then you probably shouldn't care about freezing it (you know premature optimization is root of all evil ).

Up vote 0 down vote favorite share g+ share fb share tw.

Example: If I create a Geometry inside a OnRender method and it is never used elsewhere like so: protected override void OnRender(DrawingContext dc) { base. OnRender(dc); var geometry = new RectangleGeometry(new Rect(0, 0, 100, 100)); geometry.Freeze(); dc. RenderGeometry(Brushes.

Red, null, geometry); } Does the Freeze() call here still make any difference? Wpf link|improve this question edited Mar 27 '11 at 11:14 asked Mar 18 '11 at 5:10Patrick Klug3,1761138 76% accept rate.

It depends. Freeze will make your code faster, since WPF will not care about lot of stuff any more, as freezed object cannot be modified. So if your code uses some objects frequently and it's performance issue, then you should try freezing it.

On the other hand - if code is not giving you any performance problems at all, then you probably shouldn't care about freezing it (you know, premature optimization is root of all evil). You could also use Freeze when you want to make sure, that nothing should be able to modify your object. This way, you can guarantee, that values you've set before freeze will be the same all the time.

But this is dependent on your requirements. You should also check this to get some basic idea over freezing objects and then it may become clearer when to freeze.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions