In C #,

Source: Internet
Author: User

Since C # does not allow non-creative control threads to call controls, many problems have been encountered.

Tip:

The Inter-thread operation is invalid: It is accessed by a thread that does not create the "showtable_btn" control.

Somewhat depressing

Because it was just using thread

OriginalCodeProbably as follows:

Private void showtable_btn_click (Object sender, eventargs E)

{

Thread t = new thead (s)

T. Start ()

}

 

Private void S ()

{

Textbox1.text = "www ";

}

 

If the preceding error is reported

 

So I made changes.

 

1. Add

Delegate void setvisibledelegate ();

2. Add a new function

Privare void sinvoke ()

{

This. Invoke (New setvisibledelegate (s ))

}

3. Call again later

Private void showtable_btn_click (Object sender, eventargs E)

{

Thread t = new thead (sinvoke)

T. Start ()

} In this case, everything will be OK.

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.