public TextBoxView(TextBox parent) { this.caretTimer = new DispatcherTimer(); this.caretTimer.Interval = PlatformInterface.Instance.CaretBlinkTime; this.caretTimer.Tick += this.CaretTimerTick; this.parent = parent; }
public WeakTimer(IWeakTimerSubscriber subscriber) { _subscriber = new WeakReference<IWeakTimerSubscriber>(subscriber); _timer = new DispatcherTimer(); _timer.Tick += delegate { OnTick(); }; _timer.Start(); }
public TextPresenter() { _caretTimer = new DispatcherTimer(); _caretTimer.Interval = TimeSpan.FromMilliseconds(500); _caretTimer.Tick += CaretTimerTick; Observable.Merge( this.GetObservable(SelectionStartProperty), this.GetObservable(SelectionEndProperty)) .Subscribe(_ => InvalidateFormattedText()); this.GetObservable(CaretIndexProperty) .Subscribe(CaretIndexChanged); }
/// <summary> /// Runs a method once, after the specified interval. /// </summary> /// <param name="action"> /// The method to call after the interval has elapsed. /// </param> /// <param name="interval">The interval after which to call the method.</param> /// <param name="priority">The priority to use.</param> /// <returns>An <see cref="IDisposable"/> used to cancel the timer.</returns> public static IDisposable RunOnce( Action action, TimeSpan interval, DispatcherPriority priority = DispatcherPriority.Normal) { var timer = new DispatcherTimer(priority) { Interval = interval }; timer.Tick += (s, e) => { action(); timer.Stop(); }; timer.Start(); return Disposable.Create(() => timer.Stop()); }