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
3
votes
1 answer

Producer Consumer Queue best practices and performance

I'm building a producer consummer queue in C# and I was reading for searching the best method in terms of robust and performance. For years I was using always BlockingCollection but I have discovered TPLDataflow and Channels. I'have been doing some…
3
votes
2 answers

Losing items somewhere in C# BlockingCollection with GetConsumingEnumerable()

I'm trying to do a parallel SqlBulkCopy to multiple targets over WAN, many of which may be having slow connections and/or connection cutoffs; their connection speed varies from 2 to 50 mbits download, and I am sending from a connection with 1000…
3
votes
0 answers

Interlocked Functions Don't Seem to Work as Expected in a Multithreaded PowerShell Script

I tried to utilize thread-safe DotNET classes (like BlockingCollection, ConcurrentQueue) and static functions (like Interlocked::Increment()) in my multithreaded PowerShell script (achieved through RunSpacePool), but those seem to behave in…
3
votes
1 answer

BlockingCollection.TakeFromAny, for collections with a different generic type

There is a BlockingCollection.TakeFromAny method in .NET. It first tries a fast-acquire Take and then defaults to a 'slow' method waiting on underlying Handles. I would like to use this to listen to both upstream producers supplying "Messages"…
user2864740
  • 60,010
  • 15
  • 145
  • 220
3
votes
1 answer

Creating a file pickup process with a Blocking Collection

What i have got at the moment is a timer that fires every 5000 ms: static Timer _aTimer = new System.Timers.Timer(); static void Main(string[] args) { _aTimer.Elapsed += new ElapsedEventHandler(OnTimedEvent); …
Houlahan
  • 783
  • 3
  • 19
  • 46
3
votes
1 answer

BlockingCollection worker needs to return a value via anonymous function

I have a tricky situation and was wondering if anyone could shed any light on the matter: I have a blocking collection action worker that is called like this ultraHash hash = new ultraHash(lblFolder.Text, (Action) (() => { textBox1.Text =…
Mr Heelis
  • 2,370
  • 4
  • 24
  • 34
3
votes
3 answers

blocking collection process n items at a time - continuing as soon as 1 is done

I have the following Scenario. I take 50 jobs from the database into a blocking collection. Each job is a long running one. (potentially could be). So I want to run them in a separate thread. (I know - it may be better to run them as Task.WhenAll…
Alex J
  • 1,547
  • 2
  • 26
  • 41
3
votes
1 answer

Can't add items to the collection in the second round

Basically I have a blockingcollection in my windows service application, each time I want to add 4 items to the collection then processing it. The first round is okay, but the second round failed. The error is The BlockingCollection has been…
user1108948
3
votes
3 answers

C# BlockingCollection producer consumer without blocking consumer thread

I have a situation where I need to have a large number (hundreds) of queues, where the items should be processed in order (need single threaded consumer). My first implementation, based on the samples, I used a single long-running Task per…
Mas
  • 4,546
  • 5
  • 39
  • 56
3
votes
0 answers

Insert element in a BlockingCollection

Is it possible to insert an element at first position (or a numbered position) in a -not empty- BlockingCollection? Just like with the "Insert" Method of a List. Something like: blockingCollectionObject.Insert(0, anObject);
MorgoZ
  • 2,012
  • 5
  • 27
  • 54
3
votes
0 answers

How to fix BlockingCollection / ConcurrentQueue consuming delay?

On a Windows7 quadcore with hyperthreading enabled, I have an hundred of threads comunicating via BlockingCollection (all initialized with the default constructor, thus using ConcurrentQueue internally). All threads receives 10-100 messages…
Giacomo Tesio
  • 7,144
  • 3
  • 31
  • 48
3
votes
1 answer

Making Blockingcollection observable

I have a list that is bound to a blockingcollection in my viewmodel PlantControllers { get { return…
klashagelqvist
  • 1,251
  • 2
  • 26
  • 52
3
votes
1 answer

BlockingCollection vs Subject for use as a consumer

I'm trying to implement a consumer in C#. There are many publishers which could be executing concurrently. I've created three examples, one with Rx and subject, one with BlockingCollection and a third using ToObservable from the BlockingCollection.…
2
votes
2 answers

Multiple producer/consumer interaction in .Net 4.0

I am using a BlockingCollection to process some files and then upload them to a server. Right now I have a single Producer that recurses the file system and compresses certain files to a temporary location. Once it has finished with a file it adds…
forcedfx
  • 3,388
  • 1
  • 12
  • 8
2
votes
1 answer

Cannot Add Tuple to BlockingCollection: Error CS1503 in C#

I'm working on a project that involves object detection with real-time video in C#. As part of the project, I use a BlockingCollection to manage a list of bounding boxes for detected objects, and the details for each bounding box are held in a…