问题
I need to suspend a thread on windows via Windows SDK on msys. I tried something like
std::thread thread(somefunction, someparameters);
HANDLE handle=thread.native_handle();
SuspendThread(handle);
But gcc told me the return value of native_handle() is 'long long unsigned int' but not void*. So I tried
HANDLE handle=reinterpret_cast<HANDLE>(thread.native_handle());
But it does not work because when I called GetLastError() I received the error code 6 which means the handle is invalid. What should I do?
回答1:
The returned "handle" is the thread id not the HANDLE
as returned by CreateThread.
You need to use OpenThread to get a handle from the id.
来源:https://stackoverflow.com/questions/62751283/windowswhy-does-stdthreadnative-handle-return-a-value-of-type-long-long-u