im trying to make a simple socket program. When my server send command, the client will create child thread and execute the function. It waiting for the child thread to be done. But i need the main thread still recv my command to do another work. Here is my code:
Client
int StartServices() {
HANDLE hThread;
DWORD dwThread;
hThread = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)TestFunction, NULL, 0, NULL);
if (hThread) {
return WaitForSingleObject(hThread, 10000);
}
else {
return 1;
}
}
If I got it right, You may need just to remove return WaitForSingleObject(hThread, 10000);
from the code.
int StartServices() {
HANDLE hThread;
DWORD dwThread;
hThread = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)TestFunction, NULL, 0, NULL);
if (hThread) {
//return WaitForSingleObject(hThread, 10000);
return 0;
}
else {
return 1;
}
}
So, there will be no 10 secounds waiting.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.