/// <summary> /// Adds additional information about the current thread (the thread that /// could not acquire the lock) and other locks held by the current thread and the /// thread that did acquire the lock to the <see cref="LockInfo" /> instance /// so that errors can be reported. /// </summary> /// <param name="info">The source lock information.</param> /// <param name="curStack">The current call stack.</param> /// <returns>A cloned version of the source with the additonal information.</returns> private LockInfo GetDiagnosticInfo(LockInfo info, CallStack curStack) { info = info.Clone(); info.FailNativeThreadID = GetCurrentThreadId(); info.FailManagedThreadID = Thread.CurrentThread.ManagedThreadId; info.FailStack = curStack; info.Locks = new List <LockInfo>(); info.FailLocks = new List <LockInfo>(); foreach (LockInfo l in locks.Values) { if (l.ManagedThreadID == info.ManagedThreadID) { info.Locks.Add(l); } else if (l.ManagedThreadID == info.FailManagedThreadID) { info.FailLocks.Add(l); } } return(info); }