Changed monitor function

WairForSingleObject instead of endless loop