In this answer this answer I explain in details why one should not throw System.Exception. You should be throwing InvalidOperationException
in the case of the astronomically unlikely situation, and probably an ArgumentException
in the case of the non-existing session.
As far as thread safety is concerned, I don't write multithreaded code very often so I might be completely wrong, but I since ConcurrentDictionary
is a thread-safe IDictionary
implementation, sessions.TryGetValue(id, out session)
is already a thread-safe call, doesn't need to be wrapped in a lock
block.
In this answer I explain in details why one should not throw System.Exception. You should be throwing InvalidOperationException
in the case of the astronomically unlikely situation, and probably an ArgumentException
in the case of the non-existing session.
As far as thread safety is concerned, I don't write multithreaded code very often so I might be completely wrong, but I since ConcurrentDictionary
is a thread-safe IDictionary
implementation, sessions.TryGetValue(id, out session)
is already a thread-safe call, doesn't need to be wrapped in a lock
block.
In this answer I explain in details why one should not throw System.Exception. You should be throwing InvalidOperationException
in the case of the astronomically unlikely situation, and probably an ArgumentException
in the case of the non-existing session.
As far as thread safety is concerned, I don't write multithreaded code very often so I might be completely wrong, but I since ConcurrentDictionary
is a thread-safe IDictionary
implementation, sessions.TryGetValue(id, out session)
is already a thread-safe call, doesn't need to be wrapped in a lock
block.
In this answer I explain in details why one should not throw System.Exception. You should be throwing InvalidOperationException
in the case of the astronomically unlikely situation, and probably an ArgumentException
in the case of the non-existing session.
As far as thread safety is concerned, I don't write multithreaded code very often so I might be completely wrong, but I was under the impression that asince ConcurrentDictionary
wasis a thread-safe IDictionary
implementation - so I'm not sure sessionLocks
is even needed, and I think sessions.TryGetValue(id, out session)
is already a thread-safe call, doesn't need to be wrapped in a lock
block.
In this answer I explain in details why one should not throw System.Exception. You should be throwing InvalidOperationException
in the case of the astronomically unlikely situation, and probably an ArgumentException
in the case of the non-existing session.
As far as thread safety is concerned, I don't write multithreaded code very often so I might be completely wrong, but I was under the impression that a ConcurrentDictionary
was a thread-safe IDictionary
implementation - so I'm not sure sessionLocks
is even needed, and I think sessions.TryGetValue(id, out session)
is already a thread-safe call, doesn't need to be wrapped in a lock
block.
In this answer I explain in details why one should not throw System.Exception. You should be throwing InvalidOperationException
in the case of the astronomically unlikely situation, and probably an ArgumentException
in the case of the non-existing session.
As far as thread safety is concerned, I don't write multithreaded code very often so I might be completely wrong, but I since ConcurrentDictionary
is a thread-safe IDictionary
implementation, sessions.TryGetValue(id, out session)
is already a thread-safe call, doesn't need to be wrapped in a lock
block.
In this answer I explain in details why one should not throw System.Exception. You should be throwing InvalidOperationException
in the case of the astronomically unlikely situation, and probably an ArgumentException
in the case of the non-existing session.
As far as thread safety is concerned, I don't write multithreaded code very often so I might be completely wrong, but I was under the impression that a ConcurrentDictionary
was a thread-safe IDictionary
implementation - so I'm not sure sessionLocks
is even needed, and I think sessions.TryGetValue(id, out session)
is already a thread-safe call, doesn't need to be wrapped in a lock
block.