これは私の頭の上からのテストされていないコードですが、動作する可能性がありますか?
// globally declare a map of session id to mutexes
static ConcurrentDictionary<string, object> mutexMap = new ConcurrentDictionary();
// now you can aquire a lock per session as follows
object mutex = mutexMap.GetOrAdd(session.SessionId, key => new object());
lock(mutex)
{
// Do stuff with the connection
}
mutexMap
から古いセッションをクリアする方法を見つける必要があります。 しかし、それはそれほど難しいことではありません。