Questions tagged [blockingcollection]

A .Net class that provides blocking and bounding capabilities for thread-safe collections.

A .Net class that provides blocking and bounding capabilities for thread-safe collections.

References

233 questions
0
votes
0 answers

VB.NET Event Handler as the producer of a multithreaded producer-consumer pattern

The pattern below smells for a few reasons, but for the purposes of this question, let's focus on the global variables and the event handler: Dim objectQueue As New BlockingCollection(Of Object) Dim objectQueueCancel As New…
0
votes
1 answer

Any way to know when all the Tasks in BlockingCollection finished execution?(Task will get deleted when started but I want to knowif exec is complete)

I am trying to create a single consumer and multiple producers pattern. The producers will add tasks to the BlockingCollection and Consumer will run the tasks. I want to know if there is a way to know if the execution of all the tasks spawned by…
0
votes
0 answers

Batch Processing while consuming blockingcollection

I have a blockingcollection which needs to be batch processed for 5 mins duration. Right now I am using GetConsumingEnumerable() but I don't want this instead I need to batch process. var reqs =…
0
votes
1 answer

Performance degradation over time with BlockingCollections, Tasks, and OpenCV

I'm writing a simple optical measurement application using Xamarin for Android and the OpenCV C# bindings library. In an effort to separate the frame grabber from the processing, I've created some blocking collections to pass around raw, and then…
0
votes
1 answer

How to correctly use BlockingCollection.GetConsumingEnumerable?

I'm trying to implement a producer/consumer pattern using BlockingCollection so I've written up a simple console application to test it. public class Program { public static void Main(string[] args) { var workQueue = new…
user9993
  • 5,833
  • 11
  • 56
  • 117
0
votes
1 answer

Why can I never empty the BlockingCollection?

I am downloading some JSON periodically, say every 10 seconds... When the data arrives, an event is fired. The event fired simply adds the JSON to a BlockingCollection(to be processed). I'm trying to process the JSON as fast as possible (as…
pookie
  • 3,796
  • 6
  • 49
  • 105
0
votes
1 answer

Blocking Collection stops processing for some reason

I have Blocking Collection of some lists and I process it in a task - add the data from blocking collection to database. Here is some part of the code: private static Task _databaseTask; private static readonly BlockingCollection>…
msk
  • 32
  • 4
0
votes
0 answers

BlockingCollection.GetConsumingEnumerable cancel removal

I am using GetConsumingEnumerable() to iterate over a BlockingCollection to consume data produced by another thread. I like it because it removes the items from the collection in a foreach, but there are a few cases where the item should not be…
user2258854
  • 61
  • 1
  • 1
  • 9
0
votes
1 answer

c# BlockingCollection causing out of memory

I am coding a Forex Trading robot, and I am running an outOfMemory exception after some time (around 2 hours) using BlockingCollection. I basically have 1 queue pair Trade chart, that are added into a dict: private Dictionary
bmigette
  • 59
  • 1
  • 12
0
votes
0 answers

C# Event polling and multiple Tasks

Let me briefly explain my problem. I want to read data from a sensor with my c# solution. In order to do that I use an event, which pulls the data at a very fast rate from the sensor. The data is then saved to a database in sql. To achieve that and…
DerBenutzer
  • 311
  • 1
  • 5
  • 20
0
votes
2 answers

C# Task behaviour

Hi I have a short question regarding tasks. As far as I understand Tasks can start multiple threads in itself. Lets say I have two hardware sensors which give me data over two different dataports. I want to implement them as producers in my c#…
DerBenutzer
  • 311
  • 1
  • 5
  • 20
0
votes
0 answers

BlockingCollection Consumer is repeating output

TL;DR I have an application that is reading messages from a USB device in the background, and displaying the messages on the screen. I am using a BlockingCollection, as I need to read messages quickly so the device does not get a BufferOverflow. I…
AdamMc331
  • 16,492
  • 10
  • 71
  • 133
0
votes
1 answer

Why hasn't the PriorityBlockingQueue queue to sort elements according to the priority

This my code ,the code run the end is not my excepted. I think the PriorityBlockingQueue sorted by Priority but the end is not my expected,Who can told me why. public class TestPriorityQueue { static Random r=new Random(47); public…
wanghao
  • 271
  • 1
  • 7
  • 21
0
votes
1 answer

Observing changes in a BlockingCollection without consuming

A consumer thread and multiple producer threads synchronize their work with a System.Collections.Concurrent.BlockingCollection. The producers call blockingCollection.Add() and the consumer runs foreach (var item in…
HugoRune
  • 13,157
  • 7
  • 69
  • 144
0
votes
1 answer

A variable equivalent of a blocking collection in C#

This may have an obvious answer but I will ask anyway. Is there a variable equivalent of the blocking collection for C#? What I want is for all my threads to be able to access a shared variable. It will not be a collection, just a shared variable…
Danrex
  • 1,657
  • 4
  • 31
  • 44