c# - Threading Question -


possible duplicate:
creating blocking queue<t> in .net?

i have typical producer , consumer threading issue. difference producer allowed build buffer of 5 items after has wait until items consumed.

what best solutions implement in c#. have implemented using semaphore producer seems build buffer of on 100 items rapidly. have no syntax handle limiting buffer 5 items. thinking of using static integer - have producer increment - when reaches 5 producer goes sleep. have consumer decrement , wake producer.

why don't use bounded queue (size 5) , have producer block if queue full?


Comments

Popular posts from this blog

c++ - Convert big endian to little endian when reading from a binary file -

C#: Application without a window or taskbar item (background app) that can still use Console.WriteLine() -

unicode - Are email addresses allowed to contain non-alphanumeric characters? -