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

ruby - When to use an ORM (Sequel, Datamapper, AR, etc.) vs. pure SQL for querying -

php - PHPDoc: @return void necessary? -

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