Esempio n. 1
0
        static void Main(string[] args)
        {
            Console.WriteLine($"{DateTime.UtcNow.Ticks / 10000000L} : Started");

            HWT.HashedWheelTimer timer = new HWT.HashedWheelTimer();

            timer.NewTimeout(new OneTimeTask("A"), TimeSpan.FromSeconds(5));
            timer.NewTimeout(new OneTimeTask("B"), TimeSpan.FromSeconds(4));
            var timeout = timer.NewTimeout(new OneTimeTask("C"), TimeSpan.FromSeconds(3));

            timer.NewTimeout(new OneTimeTask("D"), TimeSpan.FromSeconds(2));
            timer.NewTimeout(new OneTimeTask("E"), TimeSpan.FromSeconds(1));

            timeout.Cancel();

            System.Threading.Thread.Sleep(7000);

            Console.ReadKey();
            timer.Stop();
            Console.WriteLine($"{DateTime.UtcNow.Ticks / 10000000L} : Stopped");
            Console.ReadKey();
        }
 internal HashedWheelTimeout(HashedWheelTimer timer, TimerTask task, long deadline)
 {
     this._timer    = timer;
     this._task     = task;
     this._deadline = deadline;
 }