The Inter-thread operation is invalid: access the control from a thread that is not creating the control ~~~ Solution ~

Source: Internet
Author: User
The Inter-thread operation is invalid: It is never accessed by the thread that creates the control.
I heard that 2003 won't. I don't know if this is the case. I 've been using it for a long time ~
This problem may occur in 05, which seems to be for security ~
Oh, now we know two solutions ~

First:Control. checkforillegalcrossthreadcils= False;

When the thread starts, add this sentence. OK. No error is found ~
Everything can be used ~

Second:
With delegation, in 05, each control has an invokerequired attribute ~
Check whether it is true. If yes, the invoke operation is complete ~

 

// Create a delegate
Private   Delegate   String Returnstrdelegate ();

// The simplest drop-Value Method ~
Private   String Returnschool ()
{
ReturnCb_school.selectedvalue.tostring ();
}

// Determine whether to use invoke drops ~ If not, return directly. ~
Private   String Returncb (returnstrdelegate mydelegate)
{
If ( This . Invokerequired)
{
Return(String)This. Invoke (mydelegate );
}
Else
{
ReturnMydelegate ();
}
}

// Call other threads. ~
String _ School = Returncb (returnschool );

This is probably the case. It seems that I have heard that it is best not to use the first method. I don't know why ~
I have always used delegation, which is not very troublesome ~

Please give me a clear explanation. Thank you ~

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.