wait for events by passing in a pointer to event array