Export (0) Print
Expand All
Expand Minimize

SetEvent function

Sets the specified event object to the signaled state.

Syntax


BOOL WINAPI SetEvent(
  _In_  HANDLE hEvent
);

Parameters

hEvent [in]

A handle to the event object. The CreateEvent or OpenEvent function returns this handle.

The handle must have the EVENT_MODIFY_STATE access right. For more information, see Synchronization Object Security and Access Rights.

Return value

If the function succeeds, the return value is nonzero.

If the function fails, the return value is zero. To get extended error information, call GetLastError.

Remarks

The state of a manual-reset event object remains signaled until it is set explicitly to the nonsignaled state by the ResetEvent function. Any number of waiting threads, or threads that subsequently begin wait operations for the specified event object by calling one of the wait functions, can be released while the object's state is signaled.

The state of an auto-reset event object remains signaled until a single waiting thread is released, at which time the system automatically sets the state to nonsignaled. If no threads are waiting, the event object's state remains signaled.

Setting an event that is already set has no effect.

Windows Phone 8: This API is supported.

Windows Phone 8.1: This API is supported.

Windows Store apps can respond to named events and semaphores as described in How to respond to named events and semaphores.

Examples

For an example that uses SetEvent, see Using Event Objects.

Requirements

Minimum supported client

Windows XP [desktop apps | Windows Store apps]

Minimum supported server

Windows Server 2003 [desktop apps | Windows Store apps]

Header

WinBase.h on Windows XP, Windows Server 2003, Windows Vista, Windows 7, Windows Server 2008, and Windows Server 2008 R2 (include Windows.h);
Synchapi.h on Windows 8 and Windows Server 2012

Library

Kernel32.lib

DLL

Kernel32.dll

See also

CreateEvent
Event Objects
OpenEvent
PulseEvent
ResetEvent
Synchronization Functions

 

 

Community Additions

ADD
Show:
© 2014 Microsoft