///<summary> ///Returns an array of objects which this thread is blocked on ///</summary> public CorBlockingObject[] GetBlockingObjects() { ICorDebugThread4 th4 = m_th as ICorDebugThread4; if (th4 == null) { throw new NotSupportedException(); } ICorDebugEnumBlockingObject blockingObjectEnumerator; th4.GetBlockingObjects(out blockingObjectEnumerator); uint countBlockingObjects; blockingObjectEnumerator.GetCount(out countBlockingObjects); CorDebugBlockingObject[] rawBlockingObjects = new CorDebugBlockingObject[countBlockingObjects]; uint countFetched; blockingObjectEnumerator.Next(countBlockingObjects, rawBlockingObjects, out countFetched); Debug.Assert(countFetched == countBlockingObjects); CorBlockingObject[] blockingObjects = new CorBlockingObject[countBlockingObjects]; for (int i = 0; i < countBlockingObjects; i++) { blockingObjects[i].BlockingObject = new CorValue(rawBlockingObjects[i].BlockingObject); if (rawBlockingObjects[i].Timeout == uint.MaxValue) { blockingObjects[i].Timeout = TimeSpan.MaxValue; } else { blockingObjects[i].Timeout = TimeSpan.FromMilliseconds(rawBlockingObjects[i].Timeout); } blockingObjects[i].BlockingReason = rawBlockingObjects[i].BlockingReason; } return(blockingObjects); }
///<summary> ///Returns an array of objects which this thread is blocked on ///</summary> public CorBlockingObject[] GetBlockingObjects() { ICorDebugThread4 th4 = m_th as ICorDebugThread4; if (th4 == null) throw new NotSupportedException(); ICorDebugEnumBlockingObject blockingObjectEnumerator; th4.GetBlockingObjects(out blockingObjectEnumerator); uint countBlockingObjects; blockingObjectEnumerator.GetCount(out countBlockingObjects); CorDebugBlockingObject[] rawBlockingObjects = new CorDebugBlockingObject[countBlockingObjects]; uint countFetched; blockingObjectEnumerator.Next(countBlockingObjects, rawBlockingObjects, out countFetched); Debug.Assert(countFetched == countBlockingObjects); CorBlockingObject[] blockingObjects = new CorBlockingObject[countBlockingObjects]; for(int i = 0; i < countBlockingObjects; i++) { blockingObjects[i].BlockingObject = new CorValue(rawBlockingObjects[i].BlockingObject); if(rawBlockingObjects[i].Timeout == uint.MaxValue) { blockingObjects[i].Timeout = TimeSpan.MaxValue; } else { blockingObjects[i].Timeout = TimeSpan.FromMilliseconds(rawBlockingObjects[i].Timeout); } blockingObjects[i].BlockingReason = rawBlockingObjects[i].BlockingReason; } return blockingObjects; }