diff --git a/mono/metadata/threads.c b/mono/metadata/threads.c index f35165a27d8c0..b8fe352f4b78b 100644 --- a/mono/metadata/threads.c +++ b/mono/metadata/threads.c @@ -1158,15 +1158,23 @@ void ves_icall_System_Threading_Thread_Sleep_internal(gint32 ms) mono_thread_current_check_pending_interrupt (); - mono_thread_set_state (thread, ThreadState_WaitSleepJoin); + while (TRUE) { + mono_thread_set_state (thread, ThreadState_WaitSleepJoin); - res = SleepEx(ms,TRUE); + res = SleepEx(ms,TRUE); - mono_thread_clr_state (thread, ThreadState_WaitSleepJoin); + mono_thread_clr_state (thread, ThreadState_WaitSleepJoin); - if (res == WAIT_IO_COMPLETION) { /* we might have been interrupted */ - MonoException* exc = mono_thread_execute_interruption (thread); - if (exc) mono_raise_exception (exc); + if (res == WAIT_IO_COMPLETION) { /* we might have been interrupted */ + MonoException* exc = mono_thread_execute_interruption (thread); + if (exc) { + mono_raise_exception (exc); + } else { + // FIXME: !INFINITE + if (ms != INFINITE) + break; + } + } } }