implement a safe processing of pending events