Use proxy to bring up a progress bar form in non-Mode

Source: Internet
Author: User

Name of the progress bar displayed: processbar
Main form: form1
Function: to perform a heavy workload on form1, a progress bar is displayed in the form.

Implementation Method:

Processbar form:

In the processbar form, set formborderstyle to none and startposition to centerscreen.
Place a progressbar1 control in the center of the form
Set maximun = 20, step = 1 for the progressbar1 Control
Add:
Public void addone ()
{
If (progressbar1.value = 20)
Progressbar1.value = 0;
Progressbar1.value ++;
}

Form1 form:

In namespace, the proxy is declared before the form1 class:
Public Delegate void addprocess ();

Declare an event in the form1 class
Public event addprocess doadd;

Then add the method:
// Very large work to do
Public void dowork ()
{
String sor = "";
For (INT I = 0; I <20000; I ++)
{
Sor + = I. tostring ();
If (I % 1000 = 0)
Doadd ();
}
// MessageBox. Show (SOR );
}

To trigger a heavy workload event, write as follows:
// Button: execute a large workload string connection
Private void button10_click (Object sender, system. eventargs E)
{
Procw.ar PJ = new procw.ar ();
This. doadd + = new addprocess (PJ. addone );
PJ. Show ();
Thread Mm = new thread (New threadstart (dowork ));
Mm. Start ();
Mm. Join ();
PJ. Close ();
}

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.