Questions tagged [concurrentdictionary]

ConcurrentDictionary is a .Net thread-safe collection of key-value pairs that can be accessed by multiple threads at the same time.

ConcurrentDictionary is a .Net thread-safe collection of key-value pairs that can be accessed by multiple threads at the same time.

References

331 questions
0
votes
1 answer

How to Shim long external dependency with ConcurrentDictionary (C#) via Microsoft Fakes?

In code I need to test was found such external dependency: var something = GConfig.SConfig[Type.ServiceType1].Names; Code of this part is like this: using System; using System.Collections.Concurrent; using System.Collections.Generic; namespace…
0
votes
0 answers

C# ConcurrentDictionary AddOrUpdate

I am confused about the AddOrUpdate method. The document specifically says that the updateValueFactory is not synchronized. In the MSDN this example was given: Parallel.For(0, 10000, i => { // Initial call will set cd[1] = 1. …
Koda
  • 1,709
  • 3
  • 14
  • 15
0
votes
3 answers

Will my code ever be hit? ConcurrentDictionary TryGetValue(..)

If i have a concurrent dictionary, and i try a TryGetValue, and i test if that fails i do stuff, but if it doesn't fail, and the out value retrieved from the TryGetValuefunction is equal to what is was before i tried the TryGetValue, i do something…
jordan
  • 3,436
  • 11
  • 44
  • 75
0
votes
1 answer

Aggregating/Merging a number of concurrent dictionaries

So I have a concurrent dictionary defined as such ConcurrentDictionary>>(); I know that seems a little convoluted but the structure is valid... Now my problem is that I…
Dave Lawrence
  • 3,843
  • 2
  • 21
  • 35
0
votes
0 answers

ConcurrentDictionary.AddOrUpdate()

I am trying to use the AddOrUpdate() method in the ConcurrentDictionary class. I am having trouble with the Update peice. The following is the code: dictionary.AddOrUpdate(oid, pList, (o,p) => { for (int i=0; i < p.Count; i++) p[i] =…
Walter Kelt
  • 2,199
  • 1
  • 18
  • 22
0
votes
3 answers

Extension method Gets "No overload for method" Error

I just recently upgraded this project from ASP.Net 3.5 to 4.0 so that I could use the concurrentDictionary instead of Dictionary because of the thread safe feature. To use it I created an extension using code found in help forums. It is all very…
0
votes
1 answer

ConcurrentDictionary->AddOrUpdate in VS C++

i am using Visual Studio 2010 C++ Express and i mant to add an item to my ConcurrentDictionary: i have such code: String^ key = gcnew String("key"); int value = 123; myDictionary->AddOrUpdate(key,value,/*WHAT TO ADD HERE?*/); AddOrUpdate Method…
0
votes
1 answer

How to remove item from ConcurrentDictionary after final ContinueWith finishes

First, could someone with 1500+ "reputation" please create a tag for "ContinueWith" (and tag this question with it)? Thanks! Sorry for the length of this post but I don't want to waste the time of anyone trying to help me because I left out…
Andrew Steitz
  • 1,856
  • 15
  • 29
0
votes
2 answers

How should I keep 2 ConcurrentDictionaries in sync?

I like the lock-free operation of the ConcurrentDictionary and use it in two objects: ConcurrentDictionary myIndexByDate ConcurrentDictionary myObjectSummary Index These two objects…
0
votes
1 answer

dapper.net, how to flush ConcurrentDictionary?

I am new to dapper and plan to use it on my new project. After reading it, seems like the only problem I might have is ConcurrentDictionary. Dapper caches information about every query it runs, this allow it to materialize objects quickly and…
qinking126
  • 11,385
  • 25
  • 74
  • 124
-1
votes
0 answers

ConcurrentDictionary not working in recursive async method

This is my first work with asynchronous operations in C#, and I'm having an issue reading from a concurrent dictionary. I have a method that reads module dependencies recursively. Since this takes time, I built it so it creates multiple threads. To…
FranciscoNabas
  • 505
  • 3
  • 9
-1
votes
2 answers

I have a question of understanding in ConcurrentDictionary

I have a question of understanding. Which is the better option in terms of safety and performance? private ConcurrentDictionary chartTraderTP; if (chartTraderTP.ContainsKey(orderId)) { //Store values for later use in Mouse…
Sidlercom
  • 11
  • 4
-1
votes
2 answers

ConcurrentDictionary Add Data

Now, in my project, I have to write the data from different ipaddresses into separate lists. I am having a problem in how I will record in what order. The number of connections can be 500. The user can close and open connections as they wish. In…
user14497385
-1
votes
1 answer

ConcurrentDictionary apparently not working in ASP.NET controller

Why is the concurrent dictionary not behaving like a concurrent dictionary? [Route("aaa")] [HttpPost] public Outbound Post(Inbound inbound) { Outbound outbound = new Outbound(); TaskState taskState = new TaskState(); taskState.state =…
H2ONaCl
  • 10,644
  • 14
  • 70
  • 114
-1
votes
3 answers

ConcurrentDictionary with multiple values per key, removing empty entries

ConcurrentDictionary works well for concurrent situations when mapping keys to a single value each. When mapping to multiple values, it is easy to create a ConcurrentDictionary> and guard its addition/removal…
mafu
  • 31,798
  • 42
  • 154
  • 247