none
Does CheckForIllegalCrossThreadCalls work in non-debug mode RRS feed

  • Question

  • I've inherited a .Net 1.1 app that contains many cross thread changes to GUI components.
    I've gone through the code as best I can and fixed those that identify themselves by throwing an exception when
    Control.CheckForIllegalCrossThreadCalls is set to "true".

    However because of the size of this app I cannot guarantee that I've found all the the places that should be fixed.

    This .Net 1.1 app is in production and has been running "successfully" for a number of years now and we want to
    release the .Net 2.0 version but hesitate to do so because I understand that even with the CheckForIllegalCrossThreadCalls flag set to "false" the release version of this app will throw exceptions if there are any cross thread GUI bugs still in the code.

    So my question is: Does .Net 2.0 throw this exception regardless of the setting of the CheckForIllegalCrossThreadCalls flag when running a release version, and if so is there any other way to disable this exception without actually using .Net 1.1??
    Monday, July 7, 2008 4:54 PM

Answers

  • In .NET 2.0, CheckForIllegalCrossThreadCalls property is set just for debugging, when the winform application runs outside the debugger, it will always raise an exception if illegal cross-thread calls happen.
    Application can become multi-threaded in two ways: either by explicitly creating and running additional threads, or using a feature of the .NET framework that implicitly creates threads – such as BackgroundWorker, thread pooling, a threading timer etc.

    I'm not sure what your application looks like and what it's going to do, but if it is not developed in .NET 2.0 scale, I'm afraid you have to either rewrite codes in .NET 2.0 or just deploy it to the machines installed with .NET 1.1 and keep it running with the .NET Framework 1.1.

    Thanks.


    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    • Edited by Figo Fei Wednesday, July 9, 2008 4:38 AM phasing
    • Marked as answer by Figo Fei Monday, July 14, 2008 3:43 AM
    Wednesday, July 9, 2008 4:30 AM