Checkforillegalcrossthreadcils multiple threads operate on a control

Source: Internet
Author: User

Msdn:

If the thread that tries to access the method or attribute of the control is not the thread that creates the control, it will usually lead to unpredictable results. Generally, invalid thread activity is intended for access controlHandleAttribute error thread call. SetCheckforillegalcrossthreadcilsSetTrueIt is easier to find and diagnose the thread activity during debugging. Start the application outside the debugger.ProgramIf the cross-thread call is invalid, an exception is always thrown.

Windows Forms controls are not thread-safe in nature. If two or more threads operate on the status of a control, the control may be forced to enter an inconsistent state. Other thread-related bugs may also occur, including contention and deadlocks. It is important to ensure that controls are accessed in a thread-safe manner.
However, you can disable this exception by setting the value of the checkforillegalcrossthreadcils attribute to false. This causes the control to run in the same way as in Visual Studio 2003.

Code:

Control. checkforillegalcrossthreadcils = false;

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.