Example #1
0
        /// <summary>Cancel.In returns a new `Cancel` with its `Now` already scheduled to be called in `fromNow` duration.</summary>
        /// <param name="fromNow"></param>
        public static Cancel In(TimeSpan fromNow)
        {
            Cancel me    = new Cancel();
            Timer  timer = new Timer(fromNow.TotalMilliseconds);

            timer.AutoReset = false;
            timer.Elapsed  += (evtsender, evtargs) => {
                timer.Stop();
                timer.Close();
                timer.Dispose();
                me.Now();
            };
            timer.Start();
            return(me);
        }