public bool WaitOnBehalf(Process aProcess, Thread aThread) { ulong identifier = ((UInt64)aProcess.Id << 32) | aThread.Id; ExclLock.Enter(); bool notLocked = count > 0; if (notLocked) { count--; } else { aThread._EnterSleep(Thread.IndefiniteSleep); WaitingThreads.Add(identifier); } ExclLock.Exit(); return notLocked; }