title: show loading or progress bar in c# winforms
body: <p>I have windows application in which i need to save data into database and after saving data load crystal report to show report,all this happens on click of save button.</p>
  
  <p>I have button named <strong><code>btn_Submit</code></strong> on click of this data is saved and display report, while saving it takes time so i want to show progress bar for mean time so that user get known that data is in process.how i can do with this windows application.</p>
  
  <p>I gone through this link <a href="http://www.codeproject.com/Tips/83317/BackgroundWorker-and-ProgressBar-demo" rel="nofollow noreferrer">http://www.codeproject.com/Tips/83317/BackgroundWorker-and-ProgressBar-demo</a>  but don't get it exactly I want.</p>
  
  <p>I am aware of background worker but never used it.</p>
  
  <p>I have used background worker and progress bar as given in above link but progress bar does not stop at all once it started.</p>
  
  <p>Can any one help me?can u give any example or link that demonstrate scenario?.</p>
  
  <p>This code i added on Dowork();</p>
  
  <pre><code>private void backgroundWorker_DoWork(object sender, DoWorkEventArgs e)
  {
     PrintData arg = (PrintData)e.Argument;
     SalesMaster sm = arg.SalesData;
     BrokerMaster bm = arg.Broker;
     CustomerMaster ctm = arg.Customer;
     CompanyMaster cm = arg.Company;
     ArrayList hb = arg.Arrardata;
     int totunit = arg.totunit;
     decimal globalamt = arg.golbamt;
     SalesReport sreport = new SalesReport(sm, ctm, cm, bm, hb, totunit, glb_totalamt);
  
  
     sreport .MdiParent = arg.parentf;
  
  
     sreport .WindowState = FormWindowState.Maximized;
     sreport .Show();
  }
  </code></pre>
  
  <p>i get error on this line   <strong>sreport .MdiParent = arg.parentf;</strong> </p>
  
  <p>This error:</p>
  
  <pre><code>Cross-thread operation not valid: Control 'frmParent' accessed from a thread other than the thread it was created on.
  </code></pre>
  
  <p>what should be done here?</p>