.Net WinForm Code:
using System; using System.Collections.Generic; using System.ComponentModel;//// using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using System.Threading; namespace BackgroundWorkerSample { public partial class CalculateAddForm : Form { protected BackgroundWorker backgroundWorker1 = new BackgroundWorker(); //private int numberToCompute = 0; //private int highestPercentageReached = 0; public CalculateAddForm() { InitializeComponent(); InitializeBackgoundWorker(); } // Set up the BackgroundWorker object by // attaching event handlers. private void InitializeBackgoundWorker() { this.backgroundWorker1.WorkerReportsProgress = true; this.backgroundWorker1.WorkerSupportsCancellation = true; this.backgroundWorker1.DoWork += new DoWorkEventHandler(backgroundWorker1_DoWork); this.backgroundWorker1.ProgressChanged += new ProgressChangedEventHandler(backgroundWorker1_ProgressChanged); this.backgroundWorker1.RunWorkerCompleted += new RunWorkerCompletedEventHandler(backgroundWorker1_RunWorkerCompleted); } private long ComputeAdd(int n, BackgroundWorker worker, DoWorkEventArgs e)