public IDisposable StartTimer(DispatcherPriority priority, TimeSpan interval, Action tick) { if (_mainThread != Thread.CurrentThread) { throw new InvalidOperationException("StartTimer can be only called from UI thread"); } if (interval <= TimeSpan.Zero) { throw new ArgumentException("Interval must be positive", nameof(interval)); } // We assume that we are on the main thread and outside of epoll_wait, so there is no need for wakeup signal var timer = new X11Timer(this, priority, interval, tick); lock (_timers) _timers.Add(timer); return(timer); }
int TimerComparer(X11Timer t1, X11Timer t2) { return(t2.Priority - t1.Priority); }