DC wrote:
> 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".
No, not really. I'd call it a Producer-Consumer Queue (with 5 Consumers
in this case). And I'd use Jon Skeet's implementation:
<http://www.yoda.arachsys.com/csharp/threads/deadlocks.shtml>
>
> 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).
Don't think there are any feature changes to multithreading in 2.0 - I
believe it's stricter about cross-thread no-no's in WinForms, but that's
about it.
--
Larry Lard
(E-Mail Removed)
The address is real, but unread - please reply to the group
For VB and C# questions - tell us which version