Call backgroudworker Asynchronously

Source: Internet
Author: User

Let's take a look at a small example: C # open a control on the client. It takes about five seconds to load a lot of data in the control. If we open the control directly, it takes five seconds for the control to pop up. Of course, the user has killed it. At this time, we need to first load the control UI to the user to give it an illusion, and then load the data in the background. Let's take a look at how it works.

First, load a BackgroundWorder component in the panel, and then register several events when loading the form:

1. BackgroundWorder startup event. It is to load the code in the background for 5 seconds; The BackgroundWorder. DoWork event;

2. Events loading the BackgroundWorder. This event can be written into the current loading progress or error event; BackgroundWorder. ProgressChanged event;

3. BackgroundWorder end event. That is, when the data is loaded or an asynchronous error is prompted,

BackgroundWorder. RunWorkerCompleted event.

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.