public static bool bgl_condvar_timed_wait(condvar c, mutex o, int ms) { lock( c ) { try { bool res; bgl_mutex_unlock( o ); res = Monitor.Wait(c, ms); bgl_mutex_lock( o ); return res; } catch(Exception) { return false; } } }