Considerations for using the backgroundworker Control

Source: Internet
Author: User
The control has three events: dowork, progresschanged, and runworkercompleted. Calling the runworkerasync method in the program starts dowork event processing, when you call the reportprogress method, the event processing of the progresschanged event is started. When the dowork event is processed, the runworkercompleted event is triggered. Make sure that you do not operate any user interface objects in the dowork event handler. You should use the progresschanged and runworkercompleted events to communicate with the user interface. The progresschanged event occurs when reportprogress is called during the processing of the dowork event. Void backgroundworker1_progresschanged (Object ^ sender, progresschangedeventargs ^ e): void reportprogress (INT percentprogress) void reportprogress (INT percentprogress, object ^ userstate) the second parameter E of the progresschanged event handler has a progresspercentage attribute, which is provided by the first parameter percentprogress of reportprogress. This parameter is generally used to report the progress of the background operation, and then the progress information is obtained using the progresspercentage attribute of the second parameter E of progresschanged. If you want to pass more information, you can use the second overload of reportprogress. Its second parameter userstate will be passed to the userstate attribute of parameter E of the progresschanged event.

Considerations for using the backgroundworker Control

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.