The MASM Forum Archive 2004 to 2012

General Forums => The Campus => Topic started by: AgentSmithers on July 01, 2009, 02:16:10 AM

Title: WaitForSingleObject / Create Event
Post by: AgentSmithers on July 01, 2009, 02:16:10 AM

invoke CreateEvent,NULL,FALSE,FALSE,NULL

;Threads are created here! 10 of them!

invoke SetEvent,hEventStart
invoke SetEvent,hEventStart
invoke SetEvent,hEventStart
invoke SetEvent,hEventStart
invoke SetEvent,hEventStart
invoke SetEvent,hEventStart
invoke SetEvent,hEventStart
invoke SetEvent,hEventStart
invoke SetEvent,hEventStart
invoke SetEvent,hEventStart


ThreadProcOne PROC Param:DWORD

            invoke WriteConsoleA, STDHandle, ADDR StartOfMain, LENGTHOF StartOfMain, ecx, 0 ;Uses 2Byte Tchar's
           
            invoke WaitForSingleObject,hEventStart,INFINITE

            invoke WriteConsoleA, STDHandle, ADDR RecvEvent, LENGTHOF RecvEvent, ecx, 0 ;Uses 2Byte Tchar's
            ret


Is it normal that I must call Invoke once for each thread, It appears that if I call it once it only triggers one thread that is Sync waiting with 9 others for the same event, Why is it not triggering the event on all threads?

-Agent
Title: Re: WaitForSingleObject / Create Event
Post by: Jibz on July 01, 2009, 07:25:35 AM
http://msdn.microsoft.com/en-us/library/ms682396(VS.85).aspx

QuotebManualReset [in]

    If this parameter is TRUE, the function creates a manual-reset event object, which requires the use of the ResetEvent function to set the event state to nonsignaled. If this parameter is FALSE, the function creates an auto-reset event object, and system automatically resets the event state to nonsignaled after a single waiting thread has been released.
Title: Re: WaitForSingleObject / Create Event
Post by: AgentSmithers on July 01, 2009, 12:30:23 PM
Thanks! I knew I over looked something! I was looking for RaiseEvent I dident see it in the Synchronization Functions list =D