Important: |
---|
This is retired content. This content is outdated and is no longer being maintained. It is provided as a courtesy for individuals who are still using these technologies. This content may contain URLs that were valid when originally published, but now link to sites or pages that no longer exist. |
The CreateEventfunction creates a named or an unnamed event object.
HANDLE CreateEvent( LPSECURITY_ATTRIBUTES lpEventAttributes , BOOL bManualReset , BOOL bInitialState , LPTSTR lpName );
Parameters
If lpNamematches the name of an existing named event object, the bManualResetand bInitialStateparameters are ignored because they have already been set by the creating process.
If lpNameis NULL, the event object is created without a name.
If lpNamematches the name of an existing semaphore, mutex, waitable timer, job, or file-mapping object, the function fails and the GetLastErrorfunction returns ERROR_INVALID_HANDLE. This occurs because these objects share the same name space.
Return Values
A handle to the event object indicates success. If the named event object existed before the function call, the function returns a handle to the existing object and GetLastErrorreturns ERROR_ALREADY_EXISTS. NULL indicates failure. To get extended error information, call GetLastError.
Remarks
The handle returned by CreateEventhas EVENT_ALL_ACCESS access to the new event object and can be used in any function that requires a handle to an event object.
Any thread of the calling process can specify the event-object handle in a call to one of the wait functions. The single-object wait functions return when the state of the specified object is signaled. The multiple-object wait functions can be instructed to return either when any one of the specified objects are signaled. When a wait function returns, the waiting thread is released to continue its execution.
The initial state of the event object is specified by the bInitialStateparameter. Use the SetEventfunction to set the state of an event object to signaled. Use the ResetEventfunction to reset the state of an event object to nonsignaled.
When the state of a manual-reset event object is signaled, it remains signaled until it is explicitly reset to nonsignaled by the ResetEventfunction. Any number of waiting threads, or threads that subsequently begin wait operations for the specified event object, can be released while the object's state is signaled.
When the state of an auto-reset event object is signaled, it remains signaled until a single waiting thread is released; the system then automatically resets the state to nonsignaled. If no threads are waiting, the event object's state remains signaled.
Multiple processes can have handles of the same event object, enabling use of the object for interprocess synchronization. The following object-sharing mechanism is available: a process can specify the name of an event object in a call to the CreateEventfunction.
Use the CloseHandlefunction to close the handle. The system closes the handle automatically when the process terminates. The event object is destroyed when its last handle has been closed.
Requirements
Runs on | Versions | Defined in | Include | Link to |
---|---|---|---|---|
Windows CE OS | 1.0 and later | Winbase.h | Coredll.lib, Nk.lib |
Note This API is part of the complete Windows CE OS package as provided by Microsoft. The functionality of a particular platform is determined by the original equipment manufacturer (OEM) and some devices may not support this API.
See Also
CloseHandle, ResetEvent, SetEvent, WaitForSingleObject