| View previous topic :: View next topic |
| Author |
Message |
Guest
|
Posted: Thu Mar 24, 2005 3:48 pm Post subject: Wait a signal from another application or thread |
|
|
Hello,
My question is about how to implement "A wait for signal".
Assume that we have a thread class TMyThread drived from a TThread and its
Execute method is as following code
void __fastcall TMyThread::Execute(void)
{
while(!Terminated) {
// Do something
WaitSignalFromControllerApplication || Terminated
}//while(!Terminated)
}
TMyThread will wait until terminated or until it receive a particular signal
from another controller application or from another controller thread.
We may have multiple intances of the TMyThread and we want ALL instances be
signalled by the controller application. Controller has no knowledge about
the number of waiting threads.
How can we implement this "wait" logic? Can you give some examples?
Thx
Rieve Tulox
|
|
| Back to top |
|
 |
Remy Lebeau (TeamB) Guest
|
Posted: Thu Mar 24, 2005 7:50 pm Post subject: Re: Wait a signal from another application or thread |
|
|
<Rieve Tulox> wrote
| Quote: | How can we implement this "wait" logic? Can you give some examples?
|
Have each thread call CreateEvent(), giving the event object a unique name
string. Have the Controller call OpenEvent() using the same name string.
Then the threads can use WaitForSingleObject() to wait for the event to be
signalled.
Gambit
|
|
| Back to top |
|
 |
|