# Event notification The EC-Monitor provides event notification for a great number of events. These events are for example: - Bus state change - Link state change - Working counter errors - … Any thread can register for these events to be notified. This is achieved by calling the API function ### [EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) [emonRegisterClient](api_general.html.md#_CPPv418emonRegisterClient10EC_T_DWORD12EC_PF_NOTIFYP9EC_T_VOIDP20EC_T_REGISTERRESULTS)([EC_T_DWORD](api.html.md#_CPPv410EC_T_DWORD) dwInstanceID, [EC_PF_NOTIFY](api_general.html.md#_CPPv412EC_PF_NOTIFY) pfnNotify, EC_T_VOID \*pCallerData, [EC_T_REGISTERRESULTS](api_general.html.md#_CPPv420EC_T_REGISTERRESULTS) \*pRegResults) An example implementation for processing notifications is contained in the class `CEmNotification` of the EcMonitorDemo example, see `Examples/Common/EcNotification.cpp`. It implements the full framework to catch and process the EC-Monitor notifications. The class is instantiated once and registered at the EC-Monitor with the call [`emonRegisterClient()`](api_general.html.md#_CPPv418emonRegisterClient10EC_T_DWORD12EC_PF_NOTIFYP9EC_T_VOIDP20EC_T_REGISTERRESULTS). It contains the method `ecatNotify()` as major entry point (or callback function) for every event notification. There are two different ways events can be handled. The method of handling an event is primarily determined by the time required to handle the event and the processing context in which the event is to be handled. ## Direct event notification handling Minor events that take a very short time to process can be handled directly in the context in which they are recognized. A possible example of such an event is the detection of a false working counter (WKC). The event handling is reduced to simply issuing a log message, which is not time critical. The event is handled directly within the context of the [`emonExecJob()`](api_general.html.md#_CPPv411emonExecJob10EC_T_DWORD13EC_T_USER_JOBP19EC_T_USER_JOB_PARMS) function. ## Postponed notification handling Events that require more time-consuming processing cannot be handled directly in the context in which they are detected. The handling or processing of the event must be postponed. This is accomplished through a queue, which is also readily implemented using the `CEmNotification` class. By calling periodically `CEmNotification::ProcessNotificationJobs()`, the application checks and handles all queued notifications. #### IMPORTANT The call of `CEmNotification::ProcessNotificationJobs()` shall NOT be executed in the context of `EcMonitorJobTask()`. As the CPU time consumption may be high, this would have a high impact to the real-time behavior of the cyclic operation.