Пример #1
0
        public static IDisposable StartTimer(int priority, uint interval, Action tick)
        {
            var timer = new Timer();

            GlibTimeout.Add(priority, interval,
                            () =>
            {
                if (timer.Stopped)
                {
                    return(false);
                }
                tick();
                return(!timer.Stopped);
            });

            return(timer);
        }
Пример #2
0
        public static IDisposable StarTimer(uint interval, Action tick)
        {
            if (interval == 0)
            {
                throw new ArgumentException("Don't know how to create a timer with zero or negative interval");
            }
            var timer = new Timer();

            GlibTimeout.Add(GlibPriority.FromDispatcherPriority(DispatcherPriority.Background), interval,
                            () =>
            {
                if (timer.Stopped)
                {
                    return(false);
                }
                tick();
                return(!timer.Stopped);
            });

            return(timer);
        }