A
Analizer1
From what im reading about backgroundworker thread
it seems it can only have 1 thread at a time
is this correct
tks
it seems it can only have 1 thread at a time
is this correct
tks
Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
Analizer1 said:From what im reading about backgroundworker thread
it seems it can only have 1 thread at a time
is this correct
Of course, spacing is vital here. Do you mean a "background worker thread",Jeroen said:No.
What's more to say? You can have as many as the system reasonably
allows. If there's something else you're confused about, do ask.
[...]
//as it assigns more jobs i get -> This BackgroundWorker is
currently busy and cannot run multiple tasks concurrently.
Peter Duniho said:[...]
//as it assigns more jobs i get -> This BackgroundWorker is
currently busy and cannot run multiple tasks concurrently.
As the error explains, a given BackgroundWorker can only be running a
single background task at a time. As Jeroen points out, you can create as
many BackgroundWorker instances as you like.
There will always be a limit as to the maximum number of threads you can
have running at any given time. So even creating a new BackgroundWorker
for each task you want to start, eventually you'll exhaust the thread pool
and new BackgroundWorker instances will have to wait for
previously-started ones to complete before they can themselves start. But
that's actually a good thing.
Also, if your background task is CPU-bound, you don't really want to start
a whole bunch of them all at once anyway. For CPU-bound stuff, it's
counter-productive to have more of them running than you have CPU cores,
at least from a through-put point of view.
Pete
Peter Duniho said:[...]
//as it assigns more jobs i get -> This BackgroundWorker is
currently busy and cannot run multiple tasks concurrently.
As the error explains, a given BackgroundWorker can only be running a
single background task at a time. As Jeroen points out, you can create as
many BackgroundWorker instances as you like.
There will always be a limit as to the maximum number of threads you can
have running at any given time. So even creating a new BackgroundWorker
for each task you want to start, eventually you'll exhaust the thread pool
and new BackgroundWorker instances will have to wait for
previously-started ones to complete before they can themselves start. But
that's actually a good thing.
Also, if your background task is CPU-bound, you don't really want to start
a whole bunch of them all at once anyway. For CPU-bound stuff, it's
counter-productive to have more of them running than you have CPU cores,
at least from a through-put point of view.
Pete
i have only created 5 backbgroundworker threads
I ran 100 jobs and 3 crashed with the previous error i posted..so im just
trying to track down the cause.
Peter Duniho said:Did you create threads? Or instances of the BackgroundWorker class?
The two are not synonymous.
The issue is as I described. If you get that error, it's because you're
trying to start a new task on a BackgroundWorker that hasn't finished its
previous task.
The way to fix it is to not do that.
Pete
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.