public static SafeWaitChainHandle OpenThreadWaitChainSession() { // Get the COM APIs into WCT. I have no idea why WCT just doesn't do this itself. if (oleModule == null) { oleModule = LoadLibraryW("OLE32.DLL"); IntPtr coGetCallState = GetProcAddress(oleModule, "CoGetCallState"); IntPtr coGetActivationState = GetProcAddress(oleModule, "CoGetActivationState"); // Register these functions with WCT. RegisterWaitChainCOMCallback(coGetCallState, coGetActivationState); } SafeWaitChainHandle wctHandle = RealOpenThreadWaitChainSession(0, IntPtr.Zero); if (wctHandle.IsInvalid == true) { throw new InvalidOperationException("Unable to open the Wait Thread Chain."); } return(wctHandle); }
public WaitChainTraversal() { waitChainHandle = WaitChainNativeMethods.OpenThreadWaitChainSession(); }
private static extern bool RealGetThreadWaitChain(SafeWaitChainHandle WctHandle, IntPtr Context, WCT_FLAGS Flags, int ThreadId, ref int NodeCount, [MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 4)] [In, Out] WAITCHAIN_NODE_INFO[] NodeInfoArray, out int IsCycle);
public static bool GetThreadWaitChain(SafeWaitChainHandle chainHandle, int threadId, ref int NodeCount, WAITCHAIN_NODE_INFO[] NodeInfoArray, out int IsCycle) { return RealGetThreadWaitChain(chainHandle, IntPtr.Zero, WCT_FLAGS.All, threadId, ref NodeCount, NodeInfoArray, out IsCycle); }
private static extern bool RealGetThreadWaitChain(SafeWaitChainHandle WctHandle, IntPtr Context, WCT_FLAGS Flags, int ThreadId, ref int NodeCount, [MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 4)][In, Out] WAITCHAIN_NODE_INFO[] NodeInfoArray, out int IsCycle);
public static bool GetThreadWaitChain(SafeWaitChainHandle chainHandle, int threadId, ref int NodeCount, WAITCHAIN_NODE_INFO[] NodeInfoArray, out int IsCycle) { return(RealGetThreadWaitChain(chainHandle, IntPtr.Zero, WCT_FLAGS.All, threadId, ref NodeCount, NodeInfoArray, out IsCycle)); }