views:

15

answers:

1

I have recently upgraded a .net1.1 solution to .net2.0. AS this is a very heavy GUI appilcation with loads of controls and many multithreaded operations that update the GUI. While these operations worked seamlessly in .net1.1 it is throwing up Cross Threaded Illegal operations after the upgrade. Considering the fact that tehre are numerous grids, buttons and status labels that need to be updated via these multi threaded operations, I decided to code for checking the InvokeRequired solution, however doing that for every control would probably not be the best way to go about it.

I was wondering if you could suggest a better way of how I can go about it or propose any OOPS based class structure that I could code around to make the code look better.

Please do let me know if my question is unclear.

Thanks in advance

A: 

Here's a good article about your problem:

http://www.perceler.com/articles1.php?art=crossthreads1

The quick and dirty hack is to disable the check altogether:

static class Extensions {
   public static DisableCrossThreadCheck(this Control c){
    c.CheckForIllegalCrossThreadedCalls = false;
    foreach(var ctl in c.Controls) { 
      ctl.DisableCrossThreadCheck();
    }
   }
}

(in your form): 
this.DisableCrossThreadCheck();
Brock