BackgroundWorker Class
Framework 2.0 provide great component BackgroundWorker. Work done by thread is represented by delegate. It allows you on separate and dedicated thread. This component is mainly used for time-consuming operations like downloading data, etc.
BackgroundWorker runs time-consuming operation in background and listen events so that report for progress of operation and signal you when operation is finished. The component is available in toolbox. In window form designer it appears in component tray and properties shown in property windows.
Backgroundworker class is available under namespace System.ComponentModel and assembly is system. To setup operation add event handler for DoWork event. Call your background operation in this event handler. To start operation, call RunWorkerAsync method. ProgressChanged event notify progress of update. Once operation is complete RunWorkerCompleted event is raised.
DoWorkEventArgs.Argument property is used when operation require parameter.
Cancellation of operation can be achieved through CancelAync method. Operations are only canceled if its WorkerSupportCancellation property is true.
| Date:- 2 July, 2009 |