threads (background worker) question

  • Thread starter Thread starter csharpula csharp
  • Start date Start date
C

csharpula csharp

Hello,
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();
bw.RunWorkerAsync(param);
}

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

Thank you!
 
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
handlers.
 
Buth the question is if can I do something like that using the
background worker:

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

bw.RunWorkerAsync(2);
bw2.RunWorkerAsync(3);


and in this way create as much backgroundworkers as threads i need or
there is a better way doing it?
Thank u!
 
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

Similar Threads

Thread cancelleton (backgroundworker) 1
Thread 1
Background worker 5
Worker thread and controls 16
parallel (threads) 6
Threading question 1
Best/fastest way to abort worker thread 5
background worker and win forms 1

Back
Top