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 ToObservable with Subscribe using Reactive Extensions

I have few producers who will keeping filling into a BlockingCollection with bounded capacity of 200. I am using Reactive Extensions and calling an async method below like this, and I wanted to know if this is the correct way of implementing it…
Punit
  • 1,347
  • 3
  • 20
  • 39
0
votes
2 answers

How to clear/empty BlockingCollection in c#

I have a thread which is adding items to a BlockingCollection. I want to clear the BlockingCollection. Can somebody help me with this?
0
votes
2 answers

Marshalling exceptions across threads (without a SynchronizationContext)

I have an event handler that's calling a method synchronously. void OnSomeEventHappened(int eventInfo) { MethodDoingSomething(eventInfo); } I want to change this event handler so that the method call (to MethodDoingSomething) becomes…
0
votes
1 answer

Deadlock testing with TestSchedulers, Rx and BlockingCollection

I have the following class which basically subscribes to an int observable and multiplies the value by 2. For reality purposes I added a Thread.Sleep to simulate a heavy processing. public class WorkingClass { private BlockingCollection
Eduardo Brites
  • 4,597
  • 5
  • 36
  • 51
0
votes
1 answer

How to speed up a chunky BlockingCollection implementation

I have used many times the BlockingCollection for implementing the producer/consumer pattern, but I have experienced bad performance with extremely granular data because of the associated overhead. This usually forces me to improvise by…
Theodor Zoulias
  • 34,835
  • 7
  • 69
  • 104
0
votes
1 answer

C# BlockingCollection Dispose method

Documentation of BlockingCollection class has the following note: Always call Dispose before you release your last reference to the BlockingCollection. Otherwise, the resources it is using will not be freed until the garbage collector calls…
Nikita Sivukhin
  • 2,370
  • 3
  • 16
  • 33
0
votes
1 answer

How to use blocking.cv

When i try to run the following code rdesc <- makeResampleDesc("CV", blocking.cv = TRUE,iters=5L,folds=10) i take this error Error in makeResampleDescCV(blocking.cv = TRUE, iters = 5L, folds = 10) : unused arguments (blocking.cv = TRUE, folds =…
0
votes
0 answers

Process Limited number Of Request while buffering rest of them

I have a requirement where i have to make a lot of db calls from streaming data. In order to keep the pool from ex hosting i had to keep the calls limited. After some research i have came up with an idea of using BlockingCollection. Where i push…
0
votes
0 answers

Why does the second task wait for the first to complete?

I'm writing an application where I have a class Rechnungsleser with 2 methods and some fields. Fields: invoices = new BlockingCollection(new ConcurrentQueue()); // Total number of invoices in the XML invoicesToProcess =…
Peter
  • 1,844
  • 2
  • 31
  • 55
0
votes
1 answer

how to write json file with size limit (100KB) and once size cross, write new file?

I have a blocking collection which gets filled with data by some app1. I have subscribed to that blocking collection and need to write a file with below case, start writing a file . if the file size crossed 100kb, close the first file and starts a…
user584018
  • 10,186
  • 15
  • 74
  • 160
0
votes
1 answer

Multithreaded design for API

I'm implementing an API. The front-end will likely be REST/HTTP, back-end MSSQL, with a lightweight middle-tier in between. Probably IIS hosted. Each incoming request will have a non-unique Id attached. Any requests that share the same Id must be…
0
votes
2 answers

Messages lost when consuming from BlockingCollection in batches

I've tried to invent a method to consume a batch from BlockingCollection and got in trouble. Here's a minimal repro: internal class Program { private static readonly BlockingCollection _bc = new BlockingCollection(1000); …
0
votes
1 answer

C# blockingcollection in Swift

I am working on converting a C# application to Swift. Everything is going fine, but I am stuck at the point where the dev in the C# program used a Blocking collection: public static BlockingCollection mouseUsageMessageQueue = new…
Infiltrator
  • 309
  • 2
  • 13
0
votes
2 answers

Application unexpectedly closes while using multithreading

I was trying out a very simple Producer Consumer approach using BlockingCollection as per the article described here: MS Docs to understand multithreading. My producer is a single task which reads from an XML file (has around 4000 nodes) and pushes…
Akhoy
  • 502
  • 1
  • 13
  • 24
0
votes
0 answers

Loop through BlockingCollection without consuming

On the producer side of my program, while processing the items which will be sent to the collection, they must be checked whether a duplicate one is in the queue, so I need to loop through the BlockingCollection> at first…
ibubi
  • 2,469
  • 3
  • 29
  • 50