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

194 questions
4
votes
2 answers

Is the list order of a ConcurrentDictionary guaranteed?

I am using a ConcurrentDictionary to store log-lines, and when I need to display them to the user I call ToList() to generate a list. But the weird thing is that some users receive the most recent lines first in the list, while they should logically…
Muis
  • 8,058
  • 12
  • 71
  • 108
4
votes
2 answers

Is foreach the only way to consume a BlockingCollection in C#?

I'm starting to work with TPL right now. I have seen a simple version of the producer/consumer model utilizing TPL in this video. Here is the problem: The following code: BlockingCollection bc = new…
Girardi
  • 2,449
  • 3
  • 30
  • 45
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

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
  • 735
  • 3
  • 19
  • 43
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,497
  • 2
  • 25
  • 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,346
  • 5
  • 34
  • 54
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
  • 1,834
  • 3
  • 22
  • 47
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
  • 6,814
  • 3
  • 26
  • 43
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,192
  • 2
  • 23
  • 49
3
votes
0 answers

BlockingCollection with the ability to re-set the maximum number of items at runtime

I have a BlockingCollection that I m using in a classic publish-subscribe type example where the collection works as a buffer. When it reaches N it has to wait for the readers to consume at least one item. This works fine. Now I would like to be…
Yannis
  • 5,647
  • 4
  • 38
  • 57
3
votes
1 answer

Does GetConsumingEnumerable actually remove an item from a BlockingCollection?

The MSDN remarks at http://msdn.microsoft.com/en-us/library/dd267312.aspx state that... "The default collection type for BlockingCollection is ConcurrentQueue" Does this mean that while I am running "GetConsumingEnumerable()" on the collection, the…
Dabloons
  • 1,302
  • 15
  • 27
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.…
3
votes
1 answer

add Collection to BlockingCollection

BlockingCollection contains only methods to add individual items. What if I want to add a collection? Should I just use "foreach" loop? Why BlockingCollection doesn't contain method to add a collection? I think such method can be pretty useful.
Oleg Vazhnev
  • 21,122
  • 47
  • 154
  • 286
1 2
3
12 13