CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums
Results 1 to 2 of 2

Thread: Form.Invalidate(...)

  1. #1
    Join Date
    Jun 2001
    Melbourne/Aus (C# .Net 4.0)


    Does anyone have any idea which of these is more efficient?

    List<Rectangle> rectangles;
    //some code to build the list (up to 56 rectangles)
    // (1) is this the quickest?
    foreach (Rectangle rect in rectangles)
    // (2) or is this?
    Region region = new Region();
    foreach (Rectangle rect in rectangles)
    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.
    Last edited by rliq; April 7th, 2010 at 08:28 PM.
    Ohhhhh.... Old McDonald was dyslexic, E O I O EEEEEEEEEE.......

  2. #2
    Join Date
    Jun 2008

    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Windows Mobile Development Center

Click Here to Expand Forum to Full Width

This is a survey!

HTML5 Development Center