Example #1
0
            public IDisposable Schedule(TimeSpan dueTime, Action action)
            {
                var wait = Scheduler.Normalize(dueTime);

                var d = new BooleanDisposable();

                Action act = () =>
                {
                    if (!d.IsDisposed)
                    {
                        if (wait.Ticks > 0)
                        {
                            Thread.Sleep(wait);
                        }
                        action();
                    }
                };

                act.BeginInvoke(ar => act.EndInvoke(ar), null);

                return(d);
            }