internal ToolTipManager(SystemWindow owner) { this.systemWindow = owner; // Register listeners systemWindow.MouseMove += this.SystemWindow_MouseMove; runningInterval = UiThread.SetInterval(CheckIfNeedToDisplayToolTip, .05); }
public static bool ClearInterval(RunningInterval runningInterval) { lock (locker) { runningInterval.Shutdown(); return(intervalActions.Remove(runningInterval)); } }
/// <summary> /// Repeats a given action at every given time-interval. /// </summary> /// <param name="action">The action to execute</param> /// <param name="intervalInSeconds">The invoke interval in seconds</param> /// <returns>Action to call to cancel interval</returns> public static RunningInterval SetInterval(Action action, double intervalInSeconds) { var runningInterval = new RunningInterval(action, intervalInSeconds); lock (locker) { intervalActions.Add(runningInterval); } return(runningInterval); }
public static void ClearInterval(RunningInterval runningInterval) { lock (locker) { if (runningInterval != null) { runningInterval.Shutdown(); intervalActions.Remove(runningInterval); } } }
/// <summary> /// Repeats a given action at every given time-interval. /// </summary> /// <param name="action"></param> /// <param name="intervalInSeconds"></param> /// <returns>Action to call to cancel interval</returns> public static RunningInterval SetInterval(Action action, double intervalInSeconds) { RunningInterval runningInterval = new RunningInterval(); Action IntervalFunction = null; IntervalFunction = () => { if (runningInterval.Continue) { RunOnIdle(action, intervalInSeconds); RunOnIdle(IntervalFunction, intervalInSeconds); } }; // queue the next call and the event to run on uithread RunOnIdle(action, intervalInSeconds); RunOnIdle(IntervalFunction, intervalInSeconds); return(runningInterval); }
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); }