MessagerBox() is not thread safe. IIRC (been three years...) MessageBox() creates a new thread to poll for a response, allows the calling thread to continue, thus negating any critical sections.

Should you be using PostThreadMessage()?