C # Run the Big OP program main form card out of the solution

Source: Internet
Author: User

Wrote a program to filter large text, in which the method inside uses multi-threading, parallel threads and other methods. However, when the main form control uses this method directly, the page is stuck. So the main thread is blocked. The code below, Splitfile this method runs when the page is stuck, blocking the main thread

  Private voidButton3_Click (Objectsender, EventArgs e) {marqueeprogressbarcontrol1.visible=true; MarqueeProgressBarControl1.Properties.ShowTitle=true; Marqueeprogressbarcontrol1.text="Data Processing ... Please, later ..."; stringFile =TxtPath.Text.Trim (); Spiltfile (file,1); Marqueeprogressbarcontrol1.visible=false; }

Change to this:

    true ;             true ;             " Data Processing ... Please, later ... " ;                        New Thread (new ThreadStart (Run)); Thread. Start ();

Involves accessing controls inside a method, so use the invoke that is left specifically for the UI main thread

   this. Invoke (new EventHandler (delegate  {                thisfalse;            }));

C # Run the Big OP program main form card out of the solution

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.