0

I'm building a signalR dictionary that used to add symbols data and clients connected to a specific symbol with a specific resolution.

My classes structure looks like that

    public class Symbol
{
    public ConcurrentDictionary<string, PriceHistory> Resolutions { get; set; }
    public ConcurrentDictionary<string, string[]> connectionIdsTracker { get; set; }

}
public class PriceHistory
{
    public List<double> t { get; set; }
    public List<double> c { get; set; }
    public List<double> o { get; set; }
    public List<double> h { get; set; }
    public List<double> v { get; set; }
    public List<double> l { get; set; }
    public List<long> recSerial { get; set; }
    public string s { get; set; }
    public bool intraDay { get; set; }
}

My call to the symbol class looks like:

private static readonly ConcurrentDictionary<string, Symbol> Symbols
        = new ConcurrentDictionary<string, Symbol>(StringComparer.InvariantCultureIgnoreCase);

Is it going to make a difference to reside a concurrentdictionary inside a concurrentdictionary which is by default manage multiple reading and writing?

Also connectionIdsTracker is a dictionary of key equal to the connectionId, and value of an array that only going to have two strings symbolName and resoultion, is that a good structure or there is a better choice I can use?

E.Hamed
  • 15
  • 5
  • in this case, the symbol name is redundant in the value array of connectionIdsTracker. I think this is more a candidate for [codereview.stackexchange.com](http://codereview.stackexchange.com), it is not technically wrong but may benefit from simplifications. Is there any additional code you could show on how the data is inserted/updated/queried? – Cee McSharpface Apr 05 '17 at 07:58
  • 1
    some starting points: [Is multi-level ConcurrentDictionary still thread-safe?](http://stackoverflow.com/q/4944018/1132334), [msdn](https://social.msdn.microsoft.com/Forums/vstudio/en-US/b72eee00-0f9c-4d14-9477-cf02e7573901/nested-concurrentdictionary-is-it-a-good-idea?forum=csharpgeneral), [codeproject](https://www.codeproject.com/Articles/548406/Dictionary-plus-Locking-versus-ConcurrentDictionar) – Cee McSharpface Apr 05 '17 at 08:05
  • @dlatikay symbol name is redundant indeed, just removed it. I didn't knew that there is a codereview, thanks – E.Hamed Apr 05 '17 at 08:16
  • @dlatikay I was looking for this question answer too but wasn't able to find it thank you a lot ! – E.Hamed Apr 05 '17 at 08:18

0 Answers0