/** * Processes all of the scheduled delegates until there are no more to execute. * Sleeps when waiting for a scheduled delegate to be ready to invoke to reduce processor usage. */ static void Run() { StackTrace trace(__METHOD__, __FILE__, __LINE__); while (FutureEvents.empty() == false) { FutureEventHandler event = FutureEvents.top(); FutureEvents.pop(); Sleep(event.Time() - DateTime::Utc()); event(); } }