Comunication between threads
I am developing a program that is loaded at windows startup. At the beggining of my program, i create a thread, that has to wait for a library to be loaded. That library is loaded by windows, and I dont know when exactly is loaded.
So, in the thread, i wait for 30000 milliseconds.
After that, I assume that the library has been loaded by windows, and the thread starts its execution.
I would like to know, how can I pause (from the main program) the thread and how can I resume the execution from the main program too.
I want to know this just in the case, I am able to know when the library I need to be loaded IS loaded by windows.
Thanks in advance,
sarambur
Comunication between threads
Code:
HANDLE hThread;
BOOL
WINAPI
DllMain(
HINSTANCE hInstance,
DWORD dwReason,
LPVOID lpReserved)
{
dwThrdParam = 1;
switch (dwReason)
{
case DLL_PROCESS_ATTACH:
DisableThreadLibraryCalls ( hInstance );
hThread = CreateThread(
NULL, // no security attributes
0, // use default stack size
ThreadEscuchaTarjetaUAX, // thread function
&dwThrdParam,
0, // use default creation flags
&dwThreadId); // returns the thread identifier
// Check the return value for success.
if (hThreadTUAX == NULL)
{
MessageBox(NULL,L"CreateThread failed.",L"ERROR",MB_OK);
return(FALSE);
}
break;
case DLL_PROCESS_DETACH:
CloseHandle( hThread );
break;
default:
return(TRUE);
}//Switch
return (TRUE);
}//DllMain
I dont know what is a worker threader, so, please, have a look at the code, and see for yourself.
After the hThread is launched, I want it to pause its execution until some other events happened.
In fact, the ideal execution is:
-The tread starts its execution and waits for a signal/event/notification/ThreadNotification, whatever.
-The main program does what it has to do and tells the thread to continue the execution via a signal/event/notification/ThreadNotification, whatever again.
-The thread receives the signal/event/notification/ThreadNotification and continues the execution.
I mean something like Wait / Notify, but for windows.
Thanks in advance,
Sarambur
Comunication between threads
Hi NigelQ,
I have read the documentation for the WaitForSingleObject, and I dont know what do I have to put as a parameter in that function.
Do you have an example?
I also dont know what are kind of Objects that the WaitForSingleObject procedure can wait for.
Any example?