This project is read-only.
Multiple backgroundWorker Example.

In this small C# 4.5 windows forms application, I have created 3 separate backgroundWorkers that run simultaneously and asynchronously. All have different functions and all change object values on the main window.

The 3 backgroundWorkers are:

backgroundWorker_ProgressBar - which updates the progressBar using an asynchronous function that calculates a Fibonacci number. This example is directly from the MSDN website, here

backgroundWorkerImageLeft - which changes the background colour of the left hand picturebox with a random color while the previous backgroundWorkerProgressBar is running, and:

backgroundWorkerImageRight - which changes the background colour of the right hand picturebox with a random color, also while the backgroundWorkerProgressBar is running.

Each backgroundWorker object utilises the following methods and properties:

DoWork - Where the actual async function is called.

RunWorkerCompleted - Runs once the backgroundWorker stops.

ProgressChanged - Used to update the progress bar or any item that monitors thread progress.

WorkerReportsProgress - Set to true to enable the ProgressChanged funciton above.

WorkerSupportsCancellation - Set to true to allow cancellation of the async function.

The application, when running, looks like this:

The main window

I created this to see how multiple backgroundWorkers operate, it seems quite useful and so I thought I would upload it. Enjoy.

Last edited Jan 29, 2014 at 8:36 PM by Soran_K, version 3