|
-
Nov 1st, 2024, 10:13 AM
#1
Thread Starter
Frenzied Member
Pulling from a queue using multiple tasks
I need some help trying to accomplish something. I have a concurrentqueue defined in my program. Items get added to the queue in a sporadic fashion. It could be empty for a couple hours, then get 50-60 items added to it within seconds. I want to have multiple tasks (5 for example) that "watch" the queue for when items are added, then dequeue the items & perform a process on each one. So while the queue is empty, the tasks are idle. But if 20 items get added then the tasks "see" that there items in the queue & they dequeue & process the items, 5 at a time, until all 20 are gone. Then the tasks are idle again until items are added the the queue again. This gets repeated over & over, while the program is running. I'm not sure how to set this up so that the tasks start up when items are added. Do I need to use a loop to constantly be checking if the queue has items? That seems inefficient to me. Any help would be appreciated. Thanks...
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|