clear the event selector in a thread safe manner

Moved the sentry used to clear the event selector at the end of each event processing to be within the mutex. This makes sure all updates on that object are done in the same critical section.