Monday, November 21, 2005
« Multi-Threaded Windows Forms Application... | Main | VS.NET 200x Command Prompt Shortcut Menu... »

One thing that I failed to mention in my previous post with regard to troubleshooting applications in .NET 2.0 in which you have the potential for erroneous cross-thread calls (e.g. calls from a worker thread to a UI thread) is a new diagnostic method that can greatly simplify a developer's life.

You were kind of on your own in the 1.0 and 1.1 days for finding cross-thread method invocations and it was sometimes difficult to manage.  However, new to the world of .NET 2.0 is a static method on the Control class called  CheckForIllegalCrossThreadCalls.  This property happens to default to true in a DEBUG configuration, but it can be manually overridden.  Effectively, when set to true, the debugger will be able to identify if a control's handle is referenced by a non-UI thread and will immediately throw an exception in order to diagnose the problem.

Can save lots of digging, for sure!

Monday, November 21, 2005 9:41:00 PM (Mountain Standard Time, UTC-07:00)  #    Disclaimer  |  Comments [0]  |  Trackback