使用TID查找线程

Finding thread using TID

本文关键字:线程 查找 TID 使用      更新时间:2023-10-16

我正在构建一个基于wec7的应用程序。我有以下线程:

bool ChannelDataQueue::b_ChannelDataQueue_StartThread()
{
   m_hThread = CreateThread(NULL, 0, ChannelDataQueue::u32_ChannelDataQueue_ReadChannelData, (LPVOID)this, CREATE_SUSPENDED, NULL);
   CeSetThreadPriority(m_hThread,CE_THREAD_PRIO_256_HIGHEST);
  //SetThreadPriority(m_hThread,249);//248
  ResumeThread(m_hThread);
  return true;
}

我使用VS2008中的远程工具来监视进程和线程,但线程只显示它们所在的进程和TID/PID。我不知道如何根据ID来确定我正在监视哪个线程。

CreateThread调用的最后一个参数是指向将接收线程ID的DWORD的指针。

示例:

bool ChannelDataQueue::b_ChannelDataQueue_StartThread()
{
    DWORD threadID;
    m_hThread = CreateThread(NULL, 0, ChannelDataQueue::u32_ChannelDataQueue_ReadChannelData, (LPVOID)this, CREATE_SUSPENDED, &threadID);
    // At this point, inspect the threadID in the debugger,
    // print it to the console, write it to a file, etc...
    CeSetThreadPriority(m_hThread,CE_THREAD_PRIO_256_HIGHEST);
    //SetThreadPriority(m_hThread,249);//248
    ResumeThread(m_hThread);
    return true;
}