D
DC
Hi,
I need the functionality to take a workitem from a stack, execute it in
a different thread, get the next item, execute it asynchronously too,
and so on. But: there should never be more than 5 threads processing
workitems. As soon as the number of threads gets below five, more
workitems can be queued. This goes on until the stack of workitems is
fully processed. Not sure if that is what one would call a "Thread
Pump".
I am thinking about doing this with a .BeginInvoke() approach and a
static thread counter, but I wanted to check if somebody knows a common
pattern for my task? Also, with my approach I would do a sleep in the
main thread and periodically check if the static counter fell below 5,
but that seems clumsy to me. I don't know how to design a sync object
that can trigger program continuation whenver one of the threads
signaled that its execution finished.
On a sidenote: I am about to (finally) convert this project to
framework 2.0. Will that give me more threading options? I tested the
program (which works for years with framework 1.1) with framework 2.0
btw, and it produced a ton of "out of memory" errors (on the same
machine where it worked fine with 1.1).
Thanks for any hint in advance,
Regards
DC
I need the functionality to take a workitem from a stack, execute it in
a different thread, get the next item, execute it asynchronously too,
and so on. But: there should never be more than 5 threads processing
workitems. As soon as the number of threads gets below five, more
workitems can be queued. This goes on until the stack of workitems is
fully processed. Not sure if that is what one would call a "Thread
Pump".
I am thinking about doing this with a .BeginInvoke() approach and a
static thread counter, but I wanted to check if somebody knows a common
pattern for my task? Also, with my approach I would do a sleep in the
main thread and periodically check if the static counter fell below 5,
but that seems clumsy to me. I don't know how to design a sync object
that can trigger program continuation whenver one of the threads
signaled that its execution finished.
On a sidenote: I am about to (finally) convert this project to
framework 2.0. Will that give me more threading options? I tested the
program (which works for years with framework 1.1) with framework 2.0
btw, and it produced a ton of "out of memory" errors (on the same
machine where it worked fine with 1.1).
Thanks for any hint in advance,
Regards
DC