Event objects can be used to notify an application on reception of a CAN message automatically. This has following advantages:
The application doesn't need to check periodically for received messages any longer.
The response time on received messages is reduced.
To use events, the application must call the SetValue method to set the PcanParameterReceiveEvent parameter. This parameter sets the handle for the event object. When receiving a message, the driver sets this event to the "Signaled" state.
Another thread must be started in the application, to wait for the event to be signaled, using one of the Win32 synchronization functions (WaitForSingleObject) without increasing the processor load. After the event is signaled, the receive buffer of the Channel can be read with the Read method, and the CAN messages can be processed.
Tips for the creation of the event object:
Creation of the event as "auto-reset":
Trigger mode "set" (default): After the first waiting thread has been released, the event object's state changes to non-signaled. Other waiting threads are not released. If no threads are waiting, the event object's state remains signaled.
Trigger mode "pulse": After the first waiting thread has been released, the event object's state changes to non-signaled. Other waiting threads are not released. If no threads are waiting, or if no thread can be released immediately, the event object's state is simply set to non-signaled.
Creation of the event as "manual-reset":
Trigger mode "set" (default): The state of the event object remains signaled until it is set explicitly to the non-signaled state by the Win32
ResetEvent function. Any number of waiting threads, or threads that subsequently begin wait operations, can be released while the object's state remains signaled.
Trigger mode "pulse": All waiting threads that can be released immediately are released. The event object's state is then reset to the non-signaled state. If no threads are waiting, or if no thread can be released immediately, the event object's state is simply set to non-signaled.