-
Form.Invalidate(...)
Does anyone have any idea which of these is more efficient?
Code:
List<Rectangle> rectangles;
//some code to build the list (up to 56 rectangles)
// (1) is this the quickest?
foreach (Rectangle rect in rectangles)
this.Invalidate(rect);
// (2) or is this?
Region region = new Region();
foreach (Rectangle rect in rectangles)
region.Union(rect);
this.Invalidate(region);
OR... is it dependent on too many other factors to make a judgement?
Incidentally, in my scenario, if I use the region (2) option, then I don't need to build the list of rectangles beforehand, I can just add them to the region as they are created. This is because either the List<Rectangle> or the Region is returned from another function and not actually created in the same routine as in my example above.
-
Re: Form.Invalidate(...)
Test test test, that is the best way to determine these things. however, If I had to guess, I would assume that option A would be quickest due to the simplicity of handling rectangles as opposed to amorphous regions. Maintaining a collection of rectangles is trivial.