Споделяне чрез


EventLoop_Run Function

Header: #include <applibs/eventloop.h>

Runs an EventLoop and dispatches pending events in the caller's thread of execution.

EventLoop_Run_Result EventLoop_Run(EventLoop *el, int duration_in_milliseconds,
                                   bool process_one_event);

Parameters

  • el The EventLoop to run.

  • duration_in_milliseconds The length of time to run the event loop. If zero, the loop will process one event if one is ready and break immediately, regardless of the value of the process_one_event parameter. If greater than zero, the loop will run for the specified duration unless it is interrupted. If less than zero, the loop will keep running until interrupted. See the EventLoop_Stop function and the process_one_event parameter for additional conditions.

  • process_one_event Indicates whether to break the loop after the first event is processed. If false, the loop will keep running for the duration specified by the duration_in_milliseconds parameter, or until it is interrupted by EventLoop_Stop. This parameter is ignored if duration_in_milliseconds is zero.

Return value

Returns an EventLoop_Run_Result value that indicates results of this function call.

Remarks

An application can call EventLoop_Run(el, -1, false) to pass control of the calling thread to the EventLoop.

If the application calls EventLoop_Run(el, -1, true), the loop will block and wait until the first event is ready, then it will process the event and return.

An application can call EventLoop_Stop to exit EventLoop_Run earlier.