public void Add(NamedMethodSignature signature) { // if (signature.Name != Name) // throw new InvalidOperationException(); var c = new Count(0); c = Counts.GetOrAdd(signature, c); Interlocked.Increment(ref c.Value); Interlocked.Increment(ref _Count); }
public int GetCountOf(NamedMethodSignature signature) { Count result; if (Counts.TryGetValue(signature, out result)) { return(result.Value); } return(0); }
public void Add(NamedMethodSignature signature) { // if (signature.Name != Name) // throw new InvalidOperationException(); Count c; lock (Counts) { if (!Counts.TryGetValue(signature, out c)) { Counts.Add(signature, c = new Count()); } } Interlocked.Increment(ref c.Value); Interlocked.Increment(ref _Count); }