added message loop

basic message handling loop with option for detecting GetMessage errors