Home

SetEvent

SetEvent is a function in the Windows API used to signal an event object, a synchronization primitive that coordinates threads within a process or across processes. The event object is typically created by CreateEvent or opened with OpenEvent and identified by a handle.

The SetEvent function takes a single parameter, a handle to an event object, and marks the event

There are two reset modes: manual-reset and auto-reset. For a manual-reset event, signaling with SetEvent releases

SetEvent is commonly used in producer-consumer and synchronization scenarios where one thread signals that a condition

See also: CreateEvent, ResetEvent, OpenEvent, WaitForSingleObject, WaitForMultipleObjects.

as
signaled.
It
returns
a
nonzero
value
on
success
and
zero
on
failure;
in
case
of
failure,
callers
can
obtain
extended
error
information
with
GetLastError.
The
exact
effect
of
signaling
depends
on
the
event’s
reset
mode,
defined
when
the
event
was
created.
all
waiting
threads
and
the
event
remains
signaled
until
ResetEvent
is
called.
For
an
auto-reset
event,
signaling
releases
a
single
waiting
thread
(if
any)
and
the
event
then
automatically
resets
to
the
nonsignaled
state.
If
no
threads
are
waiting
when
SetEvent
is
called
on
an
auto-reset
event,
the
event
remains
signaled
until
a
thread
waits
on
it,
after
which
it
resets
automatically.
has
occurred,
allowing
waiting
threads
to
proceed
via
WaitForSingleObject
or
WaitForMultipleObjects.
Because
events
can
be
unnamed
or
named,
they
can
also
synchronize
across
different
processes.