/// <summary> /// Handles the DoWork event of the BgWorker control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="DoWorkEventArgs"/> instance containing the event data.</param> private void BgWorker_DoWork(object sender, DoWorkEventArgs e) { //Control comes here when RunWorkerAsync is called; ScientificCalculator scificalc = e.Argument as ScientificCalculator; e.Result = scificalc.Add(); }
/// <summary> /// Delegate the work that does the time consuming operaiton to this method /// </summary> public void TakesCareOfTimeConsumingWork() { ScientificCalculator sciFiCalc = new ScientificCalculator(); sciFiCalc.NumberOne = 1; sciFiCalc.NumberTwo = 2; bgWorker.RunWorkerAsync(sciFiCalc); }