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.
 
Back
Top