I admit that I am very card-WinForm program printing and Loading

Source: Internet
Author: User

It takes a long time for a program to click print preview and the print button gets stuck. In fact, more than this, many places will make the program not respond... In addition to BackGroundWorks, you can also use a delegate to call a buffer form.

Click to print the preview code:

 

 

Code

1 protected override void DataPrintView ()
2 {
3 Print p = new Print ();
4
5 p. PrintMethod () =>
6 {
7 if (Pager. getAllData = null)
8 {MessageBox. Show ("no data exists! "," System prompt ", MessageBoxButtons. OK, MessageBoxIcon. Information); return ;}
9 if (base. RdlcPath = null)
10 {
11 base. RdlcPath = Application. StartupPath + "\ StandardReports \" + this. Text + ". rdlc ";
12}
13 base. Repdatasource = "hitestDataSet ";
14 base. Repdatavalue = Pager. getAllData;
15 base. C1F = C1F1;
16 base. DataPrintView ();
17 });
18}

 

 

Print p = new Print ();
Is a class for processing this method.

 

The Code is as follows:

 

Code

1 public class Print
2 {
3 public delegate void Action ();
4 FrmWating Frm = new FrmWating ();
5 public void PrintMethod (Action del)
6 {
7 AsyncCallback acb = new AsyncCallback (CallBackMethod );
8
9 del. BeginInvoke (acb, del );
10 Frm. ShowDialog ();
11}
12
13 private void CallBackMethod (IAsyncResult ar)
14 {
15 Action del = (Action) ar. AsyncState;
16 if (Frm. IsHandleCreated)
17 Frm. BeginInvoke (new Action () =>{ Frm. Close ();}));
18 del. EndInvoke (ar );
19}
20}

 

 

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.