public override async Task ExecutableTask(CancellationToken token)
 {
     ConsoleAsync.WriteAt("Debounce                                                                                                     ", 0, 3);
     for (var i = 0; i < 50; i++)
     {
         if (token.IsCancellationRequested)
         {
             token.ThrowIfCancellationRequested();
         }
         else
         {
             ConsoleAsync.WriteAt("->", 9 + i, 3);
             await Task.Delay(50);
         }
     }
 }
예제 #2
0
        static void Main(string[] args)
        {
            Console.CursorVisible = false;
            Console.Write("Press any key to trigger, Escape to quit...");

            var tTest = new TestThrottledTask();
            var dTest = new TestDebouncedTask();

            ConsoleKeyInfo key = new ConsoleKeyInfo();
            while (key.Key != ConsoleKey.Escape)
            {
                var bgtask1 = tTest.Execute().ContinueWith(t => ConsoleAsync.WriteAt(t.Result.ToString(),61, 2) );
                var bgtask2= dTest.Execute().ContinueWith(t => ConsoleAsync.WriteAt(t.Result.ToString(), 61, 3) );
                key = Console.ReadKey();
            }
        }