Random number generator is a static field. Added Catch block to RegisterWaitForSingleObject callback