Asynchronous Windows Forms Programming

Source: Internet
Author: User

In a simple Windows Forms application (such as the one created by the Visual Studio. NET application wizard), all forms and controls execute on the same thread-the primordial thread used to launch the application by calling Main () -so those forms and controls can freely call each other's methods.

When a Windows Forms window invokes a call asynchronously (using a delegate) that call executes on a worker thread from the thread pool, not the thread that created the window. the completion callback method is also executed on the worker thread. as a result, the completion callback method shocould never update the user interface directly because that wocould be calling a Windows Forms form or control on a different thread from the thread that created it. similarly, progress reports triggered by the worker thread are not allowed to directly update controls such as a progress bar. in all these cases, you must complete al the call from the worker thread to the user interface thread. this is exactly what the interface ISynchronizeInvoke interface, defined in the System. componentModel namespace is designed to do.

I didn't expect that there would be such a good article in IssueVision. I had a thorough analysis of asynchronous processing. in C #1.1, I implemented the C #2.0 function and made a detailed analysis of the internal mechanism.

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.