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}