Questions tagged [concurrent-queue]

Concurrent Queue is thread-safe first in - first out (FIFO) collection.

Concurrent Queue is thread-safe first in - first out (FIFO) collection/container.

Implementations

93 questions
2
votes
1 answer

Fastest way to add List contents to ConcurrentQueue

I was reading this question and noticed the OP was iterating a list to queue up items into a ConcurrentQueue. ConcurrentQueue cq = new ConcurrentQueue(); for (int x = 0; x < TaskList.Count; x++) …
John
  • 1,124
  • 1
  • 11
  • 27
2
votes
2 answers

All items in ConcurrentQueue are identical

I have a NetworkStream that I use to get data from another program. The data arrives as a Byte[64], which I then Enqueue to a ConcurrentQueue so that another thread can dequeue for analysis later. The queue is instantiated: ConcurrentQueue
zotty
  • 797
  • 2
  • 9
  • 27
2
votes
1 answer

misunderstanding of concurrentQueue, a single consumer working from the queue on it's own thread

I'm having trouble creating a functioning SystemFileWatcher that takes the created event and stores it in a queue for a separate thread to work from. I've read countless threads here regarding this issue but I can't get my head around this…
2
votes
2 answers

Parallel.For in a List, acting upon the items in sequential order, only in the start

I have a List TaskList items that we can iterate over using a Parallel loop. The items in the list are sorted in a particular order as the TaskClass implements IComparable with its own CompareTo(object obj) method. Thus we need the items…
user4023224
2
votes
3 answers

Using Contains method in a ConcurrentQueue if T is a class or structure

I badly understand ConcurentQueue collection. How to use Contains method in a ConcurrentQueue if T is a class or structure? My code: namespace lab2Form { struct DomainName { public string domainName; …
pragmus
  • 3,513
  • 3
  • 24
  • 46
2
votes
5 answers

ConcurrentQueue Operation is giving OutofMemory Error.

I understand this question may be too general. But I tried many things and I am not able to figure out how to resolve this. I am using ConcurrentQueue for multithreading operation. One thread is downloading Images from server and saving it to queue.…
LearningAsIGo
  • 1,240
  • 2
  • 11
  • 23
2
votes
2 answers

Can I add to, and yield from a ConcurrentQueue in parallel?

I have a class that goes to get objects from a web service. My consumption of these objects is not order dependent so I issue my web requests in parallel and am adding the results to a ConcurrentQueue. At the same time, as the requests are being…
Matthew
  • 10,244
  • 5
  • 49
  • 104
1
vote
1 answer

How to properly use a ConcurrentQueue for writing in a file on a separate thread?

I have an application that receives data from outside, and I'm trying to make it so that writing this data to a file is done in a separate thread (due to the fact that writing it in the thread that received it directly caused problems with writing…
bLAZ
  • 1,689
  • 4
  • 19
  • 31
1
vote
2 answers

How to set maximum concurrent threads while dequeuing ConcurrentQueue?

I have one thread responsible for enqueuing and one thread responsible for dequeuing. However, the frequency of the data being enqueued far surpasses the time needed to dequeue + process the data. When I did the following, I ended up with a huge…
1
vote
0 answers

I get an ObjectDisposedException when reading a stream in the background service

I want to process a Request.Body in a background-service in ASP.Net Core, so I first add it to a ConcurrentQueue. public class BackgroundJobs { public ConcurrentQueue Queue { get; set; } = new ConcurrentQueue(); } The…
ChsharpNewbie
  • 1,040
  • 3
  • 9
  • 21
1
vote
0 answers

Is there any event which is called whenever an item is added to a concurrent queue?

I am storing some messages in a concurrent queue and I need to show these messages after some delay. So I need an event that gets triggered after an item is added to the queue.
Laxmi
  • 83
  • 8
1
vote
1 answer

ConcurrentQueue dequeue problem in Azure function

I have declared a ConcurrentQueue and added a list of GUIDs. Adding into the queue is fine, but when I access the queue from inside the TimerTrigger function it seems like it's empty (updateQueue.count is 0). This behavior is happening in the cloud,…
tt0206
  • 747
  • 3
  • 9
  • 24
1
vote
1 answer

C# Abortable Asynchronous Fifo Queue - leaking massive amounts of memory

I need to process data from a producer in FIFO fashion with the ability to abort processing if the same producer produces a new bit of data. So I implemented an abortable FIFO queue based on Stephen Cleary's AsyncCollection (called…
Stephan Steiner
  • 1,043
  • 1
  • 9
  • 22
1
vote
1 answer

C# concurrent queue usage

got a quick question. Do I have to use a concurrent queue if one thread is enqueuing and other is dequeuing? Is there any race condition/other risk when using regular container in this scenario (1 reader & 1 writer)?
1
vote
3 answers

How to handle data coming from multiple threads in one thread (with ConcurrentQueue)?

I have orders coming in from multiple threads and I want to process this data in one thread. If I understood it right, the way to do it is with ConcurrentQueue. I had a look at SO question How to work threading with ConcurrentQueue, but it did…
RWC
  • 4,697
  • 2
  • 22
  • 29