有没有办法通过 Profiling API ICofProfilerInfo 或 IMetadataImport 接口或任何其他方式从非托管代码中读取托管线程的 System.Thread.ThreadState 属性?
例如这样的:
ICorProfilerInfo3 pProfilerInfo = ...;
ThreadID threadId;
pProfilerInfo->GetCurrentThreadID(&threadId);
ThreadState threadState;
pSomethingWhatINeed->GetManagedTheadState(threadId, &threadState);
if(threadState == THREADSTATE_WAIT_JOIN_SLEEP){
//do something
}