Questions tagged [concurrent-collections]

Concurrent Collections are several collection implementations in .Net that support multi-threaded access in a safe and efficient way

Concurrent Collections are several collection implementations in .Net that support multi-threaded access in a safe and efficient way. Some of those collections are ConcurrentQueue, ConcurrentStack, ConcurrentBag.

References

98 questions
1
vote
2 answers

Parallel foreach ConcurrentDictionary add

I have entries like in a phone book: name + address. The source is on a web site, the count is over 1K records. Question is: How do i use/implement ConcurrentDictionary with ParallelForeach? I might as well ask will it better perform:…
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

Validation of object within a list in Parallel C#

I'm implementing an import functionality, wherein I need to read the data from the user uploaded CSV or Excel file and run a few validations and sanitize the data before writing the data to DB. I'm able to get the data from the file to a list of…
0
votes
1 answer

What happens to the additional return value if the GetOrAdd() ValueFactory is called multiple times?

In a C# Concurrent Dictionary, specifically the signature . . . public TValue GetOrAdd(TKey key, Func valueFactory) . . . I know it is possible for valueFactory to be called multiple times. What happens to the multiple return values…
Chuu
  • 4,301
  • 2
  • 28
  • 54
0
votes
1 answer

Do concurrent collections cache the enumerator snapshots?

If I understood correctly, then the concurrent collections create a snapshot as a source for the Enumerator used in a foreach loop, which requires locking. Do they cache the snapshots or lock every time? Does this have a potential performance…
mike
  • 1,627
  • 1
  • 14
  • 37
0
votes
1 answer

Is WPF binding to concurrent collections safe?

I was wondering, if it is safe to bind a WPF control to a concurrent collection, specifically a wrapper class around one of the System.Collections.Concurrent collections that also implements INotifyCollectionChanged? I understand that…
mike
  • 1,627
  • 1
  • 14
  • 37
0
votes
1 answer

control number of threads used in cnc/tbb

I am using intel cnc library and it creates as many threads as there are cores. Is there any way to control the number of threads used for the purpose and possibly control their placement.
Kabira K
  • 1,916
  • 2
  • 22
  • 38
0
votes
1 answer

Blocking producer until collection reaches half of it's capacity using System.Collections.Concurrent.BlockingCollection

I have a "single producer/single consumer" scenario implemented with new BlockingCollection of .NET 4.0. The problem is that the producer thread awakes as soon as there's as a single space beocmes free in the collection. I want the producer to block…
Xaqron
  • 29,931
  • 42
  • 140
  • 205
0
votes
1 answer

Why does ConcurrentQueue.Enqueue method not add a value?

I define ConcurrentQueue as a ViewModel class field in my WPF MVVM application: private ConcurrentQueue _agcAbsoluteDataRecordsToSaveBuf = new ConcurrentQueue(); Below is AGC_DataRecordToSave…
Prohor
  • 141
  • 1
  • 3
  • 12
0
votes
2 answers

Multithread queue of jobs

I have a queue of jobs which can be populated by multiple threads (ConcurrentQueue). I need to implement continuous execution of this jobs asynchronously(not by main thread), but only by one thread at the same time. I've tried something like…
0
votes
1 answer

Updating concurrent collection

I am working on a multi-thread application, where I load data from external feeds and store them in internal collections. These collections are updated once per X minutes, by loading all data from the external feeds again. There is no other…
0
votes
1 answer

BlockingCollection default accessor

I am working with the BlockingCollection and have run into issues in attempting to serialize it. The error occurs on the new XmlSerializer line. The error is: You must implement a default accessor on…
S.Davis
  • 3
  • 1
0
votes
0 answers

Data structure for implementing an Address Book in Java

Which data structure from the Concurrent collections package will be suitable for implementing an address book?
java_geek
  • 17,585
  • 30
  • 91
  • 113
0
votes
2 answers

Concurrent collections is it safe to modify from different threads

Let say I have: MyCollection = new ConcurrentDictionary(); I now it is safe to add and remove items from MyCollection . But What about modifying items. For example is it safe to do: MyCollection["key"] = 1; // thread…
Tono Nam
  • 34,064
  • 78
  • 298
  • 470
0
votes
1 answer

PLinq and Object Pooling using ConcurrentCollections

I have a method that has to iterate over a large set of data and returned the processed results to a consumer thread for serialization. Streaming PLinq fits best performance-wise. Because these operations are frequent, i am using an objectpool to…
anchandra
  • 1,089
  • 12
  • 23