/// <summary> /// Sleep for "duration" number of seconds. However, if during the sleep that the wakeupCall fuction returns true, then Sleep will exit immediately. /// </summary> /// <param name="wakeupCall"></param> /// <param name="duration"></param> public static void Sleep(WakeFunction WakeupCall, int duration) { for (int i = 0; i < duration; i++) { if (WakeupCall()) { break; } Thread.Sleep(1000); } }