0
votes

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

1 Answers

2
votes

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.