Click to See Complete Forum and Search --> : CEvent problem


Andrew Truckle
April 28th, 1999, 08:55 AM
I have a CEvent called threadEnd.

I signal the event to terminate the thread with threadEnd.SetEvent().

Then, in the thread I want to check that it is signalled. BUT, in some places I only want to see if it is signalled so as to adjust the status text. When the particular loop is finished, then it will check again and close the thread.

This is due to the interface libraries I am using and must use this method.

The problem is that when I poll to see if the event is signalled it seems to reset itself. So at the moment I have resorted to a simple global variable.

Can anyone offer me some help?

M Grundberg
April 28th, 1999, 09:25 AM
The event is by default automatic, as you have noticed. But you can construct it as a manual-reset event:

CEvent( BOOL bInitiallyOwn = FALSE, BOOL bManualReset = FALSE, LPCTSTR lpszName = NULL, LPSECURITY_ATTRIBUTES lpsaAttribute = NULL );

Just set bManualReset to TRUE in the constructor. But this mean that when your loop is finished and you check the event, you must manually reset the event with CEvent::ResetEvent.

/Michael Grundberg
M.Sc. Computer Science
Visionova IT-System, Sweden
michael@itsystem.se

Andrew Truckle
April 28th, 1999, 09:31 AM
Hi

I will look into doing what you said.

May I ask you what code you would use to check the event?