threads (background worker) question


csharpula csharp

I got a question regarding the usage of background worker.
How can I run few threads via background worker with different objects
as parameter each time.

I understood that I can't do this:

for (int i = 0; i < inputNum; i++)
string param = i.ToString();

So,how can I do it by running few threads with one background worker?

Thank you!

William Stacey [C# MVP]

1 worker - 1 thread. You could spawn other threads inside the worker.
You may also want to look at the CCR in the robotics studio. It is not the
api that is so interesting, it is the non-blocking pattern using ports and

csharpula csharp

Buth the question is if can I do something like that using the
background worker:

BackgroundWorker bw = new BackgroundWorker();
BackgroundWorker bw2 = new BackgroundWorker();


and in this way create as much backgroundworkers as threads i need or
there is a better way doing it?
Thank u!

William Stacey [C# MVP]

Yes you can do that. Create as many as you need (and resource permits). I
thought you asked if you could do multiple threads with 1 BW.

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question