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

BlockingCollection stops taking after few iterations

In its bare-bone, my producer/consumer pattern reads as the following. public class Consumer { Task consumer; BlockingCollection buffer; public Consumer() { buffer = new(); consumer = Task.Factory.StartNew( …
Dr. Strangelove
  • 2,725
  • 3
  • 34
  • 61
0
votes
2 answers

BlockingCollection alternatives?

We are using BlockingCollection to implement producer-consumer pattern in a real-time application: BlockingCollection collection = new BlockingCollection(); CancellationTokenSource cancellationTokenSource = new CancellationTokenSource(); //…
alexk
  • 143
  • 1
  • 11
0
votes
1 answer

async use with FileSystemWatcher in Net 5

I'm trying to create an application in Net 5 that watches a folder and any time files are being dropped in the folder, it should run a certain set of tasks (getting some info from the files, copy them to new location, among others). I thought I…
CMorgan
  • 645
  • 2
  • 11
  • 33
0
votes
1 answer

Saving images via producer-consumer pattern using BlockingCollection

I'm facing a producer-consumer problem: I have a camera that sends images very quickly and I have to save them to disk. The images are in the form of ushort[]. The camera always overrides the same variable of type ushort[]. So between one…
dpoli
  • 1
  • 1
0
votes
1 answer

await completion of BlockingCollection

For a multithreaded application I want to await until a BlockingCollection is completed and empty (IsCompleted = true). I implemented the below and this seems to be working. Since it's multithreading I don't even trust my own shadow. Would this be a…
0
votes
0 answers

MemoryCache Update List in Thread Safe Manner

I'm trying to fully understand the implications of thread safety in maintaining a BlockingCollection inside a MemoryCache The scenario: log recent users that request any page from a site. Use an action filter on the controller to async log their…
jleach
  • 7,410
  • 3
  • 33
  • 60
0
votes
1 answer

Asp.net core Web API parallel call , batch processing with some data lost

Created one web API in asp.net core 3.x which is responsible to save data in to Azure service bus queue and that data we will process for reporting. API load is too high so we decided to save data in-memory for each request. Once data limit…
V_B
  • 1,571
  • 5
  • 16
  • 37
0
votes
2 answers

Are multiple consumers in BlockingCollection handled concurrently?

I have a BlockingCollection which I write to from one thread and I read from another. The producer thread takes items received from a server and adds them to the BlockingCollection, while the reading thread attempts to empty the BlockingCollection…
ulak blade
  • 2,515
  • 5
  • 37
  • 81
0
votes
1 answer

Strange behavior of starting multiple tasks that block

Here is a test method that starts (without awaiting) 100 Tasks that each call GetConsumingEnumerable on a BlockingCollection. (Update: the behavior described below is not specific to this method; it could be any synchronously blocking method call.)…
Mo B.
  • 5,307
  • 3
  • 25
  • 42
0
votes
0 answers

C# WebAPI Thread Aborting when Sharing Data Access Logic

I'm getting the following error on my C# Web API: "Exception thrown: 'System.Threading.ThreadAbortException' in System.Data.dll Thread was being aborted". I have a long running process on one thread using my data access logic class to get and…
0
votes
0 answers

Will BlockingCollection or TPL will be suitable for multiple producer-consumer scenario

Will only BlockingCollection or TPL with BlockingCollection will be suitable for this case: program will gather data from multiple socket streams (will act as client). Get Packet from socket, forward it to the central processor. Central processor…
0
votes
0 answers

Why use while(true) with .take with a blockingcollection?

I have been looking into using blockingcollection. I found this article very helpful Although, he is using "tasks" for multi threading purposes, I don't think I need this. But anyways, the author demonstrate 2 ways to iterate through the collection…
XCELLGUY
  • 179
  • 2
  • 12
0
votes
1 answer

VB.net - 5 threads reading/writing to the same variable

I have an app that uses 5 concurrent threads to perform tasks. The threads will need to read from a list of items and pick the next available one. As soon as they've done so, they need to add one to the counter so that the next thread is able to…
Ed Jones
  • 321
  • 1
  • 2
  • 11
0
votes
1 answer

Take method of BlockingCollection slower?

I was using BlockingCollection to queue data received over network and process it. I was consuming from the blockingcollection at every 100 ms in a timer. But I found that consumer was slow and length of blockingcollection was ever increasing. Since…
Arctic
  • 807
  • 10
  • 22
0
votes
1 answer

Why does BlockingCollection slow down as you add more threads to it?

I am doing some profiling of the BlockingCollection with a view for using it in a UDP Data processing scenario. Currently it is being used in a single consumer fashion with incoming UDP data being written to the collection and then processed…