Invoke and begininvoke

Source: Internet
Author: User

1. Delegate invoke and begininvoke
1.1. Delegate. Invoke
Delegate. Invoke is used to execute a delegate on the current thread. We know that the delegate is a reference to a function or method, and delegate. Invoke is the call

Use methods or functions.

1.2. Delegate. begininvoke
Delegate. begininvoke is used to asynchronously execute a delegate and execute it in a separate thread, so it does not block the current thread. Before calling

After delegate. bigininvoke, you must call endinvoke at a certain time to avoid resource leakage. Because the delegate method is in a separate thread

Attributes of the new UI thread or call any methods that may update the UI. For example, if you want to update a progress bar and fill in a list or other similar work,

A different mechanism must be used: Control. invoke or control. begininvoke.

2. Control invoke and begininvoke
2.1. Control. Invoke
It is used to execute delegation in the UI thread where the control is located. If you have a delegate for updating the UI, you can call control. Invoke from other threads to execute more

New operation.

2.2. Control. begininvoke
Control. begininvoke does the same thing. The difference is that it is asynchronous. That is to say, Control. Invoke waits for the UI thread to complete the update operation, while

Control. begininvoke returns immediately without blocking the current thread.

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.