Esempio n. 1
0
        public static void ExecuteWhen(Func <bool> readyCondition, Action actionToExecute, double secondsBeforeRecheck = .1, double maxSecondsToWait = 1)
        {
            long            startTime = UiThread.CurrentTimerMs;
            RunningInterval interval  = null;

            void WaitForCondition()
            {
                var ready = readyCondition();

                if (ready || UiThread.CurrentTimerMs > startTime + maxSecondsToWait * 1000)
                {
                    if (ready)
                    {
                        actionToExecute();
                    }
                    UiThread.ClearInterval(interval);
                }
            }

            interval = UiThread.SetInterval(WaitForCondition, secondsBeforeRecheck);
        }
Esempio n. 2
0
 public void Dispose()
 {
     // Unregister listeners
     systemWindow.MouseMove -= this.SystemWindow_MouseMove;
     UiThread.ClearInterval(runningInterval);
 }