Tutorial by Examples

Once the instance of the BackgroundWorker has been declared, it must be given properties and event handlers for the tasks it performs. /* This is the backgroundworker's "DoWork" event handler. This method is what will contain all the work you wish to have your progra...
This allows the BackgroundWorker to be cancelled in between tasks bgWorker.WorkerSupportsCancellation = true; This allows the worker to report progress between completion of tasks... bgWorker.WorkerReportsProgress = true; //this must also be used in conjunction with the ProgressChanged event...
A BackgroundWorker is commonly used to perform tasks, sometimes time consuming, without blocking the UI thread. // BackgroundWorker is part of the ComponentModel namespace. using System.ComponentModel; namespace BGWorkerExample { public partial class ExampleForm : Form { ...
The following example demonstrates the use of a BackgroundWorker to update a WinForms ProgressBar. The backgroundWorker will update the value of the progress bar without blocking the UI thread, thus showing a reactive UI while work is done in the background. namespace BgWorkerExample { public...

Page 1 of 1