title: While updating a value in concurrent dictionary is better to lock dictionary or value
body: <p>I am performing two updates on a value I get from TryGet I would like to know that which of these is better?</p>
  <p>Option 1: Locking only out value?</p>
  <pre><code>if (HubMemory.AppUsers.TryGetValue(ConID, out OnlineInfo onlineinfo))
  {
      lock (onlineinfo)
      {
          onlineinfo.SessionRequestId = 0;
          onlineinfo.AudioSessionRequestId = 0;
          onlineinfo.VideoSessionRequestId = 0;
      }
  }
  </code></pre>
  <p>Option 2: Locking whole dictionary?</p>
  <pre><code>if (HubMemory.AppUsers.TryGetValue(ConID, out OnlineInfo onlineinfo))
  {
      lock (HubMemory.AppUsers)
      {
          onlineinfo.SessionRequestId = 0;
          onlineinfo.AudioSessionRequestId = 0;
          onlineinfo.VideoSessionRequestId = 0;
      }
  }
  </code></pre>