Is there a way to send data to a BackgroundWorker after it has been started?

backgroundworker, c#, concurrency, multithreading, parameters

Solution

You'll need to add some synchronization, and have a place for the background worker to read data from.

You can't (easily) SEND data to the background worker. It's much easier to just have a place where the worker can look for data, and you can just add data to process. Just make sure to put synchronization in place on that point, since (at least) two threads will be accessing the data at potentially the same time.

Problem

I know you can pass arguments through the RunWorkerAsync function call when you first start the backgroundworker, but can you pass it data after its already been started? Or would I need to create my own form of concurrency to handle passing data to it from a different thread?

Original source