Example #1
0
        public IList <WaitChainNode> Traverse(Int32 threadId, OutOfProcess flags, out Boolean isCycle)
        {
            const Int32 c_ErrorIOPending = 997;
            Int32       nodeCount        = c_MaxNodeCount;

            Byte[] nodeBytes = new Byte[nodeCount * c_SizeOfWaitChainNode];
            //GCHandle gch = GCHandle.Alloc(nodeBytes, GCHandleType.Pinned);  // TODO: Async - pin bytes
            Boolean ok = GetThreadWaitChain(m_wct, IntPtr.Zero, flags, threadId, ref nodeCount, nodeBytes, out isCycle);

            if (!ok)
            {
                Int32 error = Marshal.GetLastWin32Error();
                Console.WriteLine("error:{0}", error);
                if (error == c_ErrorIOPending)
                {
                    return(new List <WaitChainNode>());
                }
                return(new List <WaitChainNode>());
            }
            Array.Resize(ref nodeBytes, nodeCount * c_SizeOfWaitChainNode);
            return(BytesToWaitChainNodeInfoList(nodeBytes));
        }
 private static extern Boolean GetThreadWaitChain(SafeWctHandle wctHandle, IntPtr context, OutOfProcess flags, Int32 threadId,
    ref Int32 nodeCount, Byte[] nodeBytes, [MarshalAs(UnmanagedType.Bool)] out Boolean isCycle);
 public IList<WaitChainNode> Traverse(Int32 threadId, OutOfProcess flags, out Boolean isCycle) {
     const Int32 c_ErrorIOPending = 997;
     Int32 nodeCount = c_MaxNodeCount;
     Byte[] nodeBytes = new Byte[nodeCount * c_SizeOfWaitChainNode];
     //GCHandle gch = GCHandle.Alloc(nodeBytes, GCHandleType.Pinned);  // TODO: Async - pin bytes
     Boolean ok = GetThreadWaitChain(m_wct, IntPtr.Zero, flags, threadId, ref nodeCount, nodeBytes, out isCycle);
     if (!ok) {
         Int32 error = Marshal.GetLastWin32Error();
         Console.WriteLine("error:{0}", error);
         if (error == c_ErrorIOPending) return new List<WaitChainNode>();
         return new List<WaitChainNode>();
     }
     Array.Resize(ref nodeBytes, nodeCount * c_SizeOfWaitChainNode);
     return BytesToWaitChainNodeInfoList(nodeBytes);
 }
Example #4
0
 private static extern Boolean GetThreadWaitChain(SafeWctHandle wctHandle, IntPtr context, OutOfProcess flags, Int32 threadId,
                                                  ref Int32 nodeCount, Byte[] nodeBytes, [MarshalAs(UnmanagedType.Bool)] out Boolean isCycle);