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

BlockingCollection is taking too much time to wake up

I have an issue when BlockingCollection is taking too much time to wake up from .Take() call. The scenario is this: I have a thread that pushing data to BlockingCollection very fast (actually in XUnit i did a for loop. I have a 3 Task that…
Alex F
  • 3,180
  • 2
  • 28
  • 40
0
votes
1 answer

file writing using blockingcollection

I have a tcp listener which listens and writes data from the server. I used a BlockingCollection to store data. Here I don't know when the file ends. So, my filestream is always open. Part of my code is: private static BlockingCollection
tony montana
  • 105
  • 1
  • 13
0
votes
1 answer

.NET BlockingCollection CPU usage

Running this program will chew up 25% CPU power in a four cores system. So basically something is running at full thrust. I narrowed it down to the consumer however the load doesn't stop on pressing "x" which should terminate my consumers. my…
lapsus
  • 2,915
  • 2
  • 32
  • 61
0
votes
1 answer

Why BlockingCollection doesn't implement IProducerConsumerCollection?

I recently needed an IProducerConsumerCollection implementation but I wanted it to block on TryAdd if a certain capacity has been reached and block on TryTake if it's empty. I was certain that BlockingCollection is actually an implementation of…
Yannis
  • 6,047
  • 5
  • 43
  • 62
0
votes
2 answers

Oracle connection issue while using tasks and blocking collection

I have some tasks (nWorkers = 3): var taskFactory = new TaskFactory(cancellationTokenSource.Token, TaskCreationOptions.LongRunning, TaskContinuationOptions.LongRunning, TaskScheduler.Default); for (int i = 0; i < nWorkers; i++) { var…
Mario Arturo
  • 347
  • 3
  • 9
0
votes
1 answer

BlockingCollection.TryTake() exceeds timeout

In my app, I have several threads for handling TCP connection (one for reading, one for sending, one for handling new incomming connections). Each thread handles the given type of operation for all clients, so lets say it sends data to 5 TcpClient…
0
votes
1 answer

PC Queue using TPL?

Original How would I create a Producer-Consumer Queue in C# leveraging the TPL and/or Concurrent Collections? I'm using .NET 4.5+. Here's my first attempt: public class SampleFileProcessor { private readonly BlockingCollection _queue = …
Lee Grissom
  • 9,705
  • 6
  • 37
  • 47
0
votes
2 answers

Finish two tasks then printing something

I have three tasks, one is producer, then consumer and the last one is to print something after finishing the first two. However the code doesn't reach the last task, which means no printing. while (true) { …
user1108948
0
votes
1 answer

Consumer/Producer with BlockingCollection appears slow

I am getting data from an external socket connection through the "Producer" below. I place the data into a BlockingCollection, which is then read by the consumer. If the consumer does NOT receive data within a fixed period, it fires off anyway, such…
ManInMoon
  • 6,795
  • 15
  • 70
  • 133
0
votes
1 answer

Add items to a BlockingCollection

Orginnally I had a BlockingCollection BlockingCollection ChannelQueue = new BlockingCollection(); I added the items to it. ChannelResource ChanResource = TelephonyServer.GetChannel(); …
user1108948
0
votes
1 answer

Why Backgroundeworker + BlockingCollection Combination is slower?

I have a program accessing database and downloading images. I was using BlockingCollection for that purpose. However, to access some UI elements I decided to use combination of Backgroundworker and BlockingCollection. It reduced speed of processing…
LearningAsIGo
  • 1,240
  • 2
  • 11
  • 23
0
votes
1 answer

How to add a custom message pump supporting parameters?

This is related to this question: How to create custom message pump? I basically need the same message pump, except it also needs to be able to support input parameters. The answer from the question above, only supports Action() delegates, which…
Eternal21
  • 4,190
  • 2
  • 48
  • 63
0
votes
1 answer

Basic BlockingCollection Producer Consumer in VB.NET

I have been struggling for the last few hours to get a basic implementation of BlockingCollection to work. I cannot seem to find a tutorial in VB.NET for the life of me, so have been trying to get something working from tutorials in C#. I just want…
Henry Ing-Simmons
  • 1,362
  • 5
  • 18
  • 25
0
votes
1 answer

Blocking collection - Remove a specific element

I'm using a blocking collection as I need this list to be thread safe: Orders = new BlockingCollection(); I'm trying to remove a specific order, lets say I want to remove order.ID 1 if it was a normal collection would be something like…
Joao Raposo
  • 135
  • 8
0
votes
2 answers

Strange Behavior with Threading and Timer

I explain my situation. I have a producer 1 to N consumers pattern. I'm using blocking collections and everything is working well. Doing some test I noticed this strange behavior: I was testing how long my manipulation of data took in my…
qwark
  • 493
  • 1
  • 4
  • 15