mike mcintyre's

.N e t J o u r n a l

vbCity Blogs moved to:
http://cs.vbcity.com/blogs
  Home :: Syndication  :: Login

OctNovember 2009Dec
SMTWTFS
25262728293031
1234567
891011121314
15161718192021
22232425262728
293012345

Archives

Topics

Source Code

The BackgroundWorker Class, new in .NET 2.0, makes threading your application operations easier.

Use the BackgroundWorker class to create a BackgroundWorker object that can execute an operation on a separate thread. Processing on a separate thread makes it possible to maintain a responsive user interface while running a time consuming operation in the background.

A BackgroundWorker object can be created programmatically or by dragging it onto a form from the Components tab of the Toolbox.

Add a DoWork handler to listen for the BackgroundWorker object's DoWork event. Call the time-consuming operation in this event handler.

To receive and process notifications of background operation progress from the BackgroundWorker object, add an event handler to listen for the BackgroundWorker object's ProgressChanged events. For example, you could update a progress bar each time a ProgressChanged event is raised.

To receive and process the notification from the BackgroundWorker object that a background operation has completed, add an event handler to listen for the BackgroundWorker object's RunWorkerCompleted event.

Click the link below to download Visual Basic source code in a Visual Studio 2005 solution which demonstrates how to use the BackgroundWorker class to execute a background operation on a separate thread.

BackgroundWorker Class Example Source Code

posted on Sunday, August 27, 2006 2:18 PM