Suspend and resume the main thread in C for windows
•
Java
I need to be able to pause and resume the main thread in Windows C applications I used it
handle = GetCurrentThread(); SuspendThread(handle);
Then where should it be restored
ResumeThread(handle);
Pause its work and resume it I have other threads suspended and resumed. No problem. Is there something different from the main thread
I've done a lot of threading work in c# and Java, but this is the first time I've done anything in C, and I find it a little different
Solution
Do you use the "handle" value obtained by getcurrentthread() in another thread? If so, it is the value of forgery To get the real thread handle, use the DuplicateHandle or try
HANDLE hThread = OpenThread(THREAD_ALL_ACCESS,FALSE,GetCurrentThreadId());
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
二维码