public async Task RunAsync()
        {
            while (true)
            {
                Console.WriteLine("sleeping");
                await Task.Delay(1000);

                await _pauseToken.WaitWhilePausedAsync();

                Console.WriteLine("Is Paused = {0}", _pauseToken.IsPaused);
            }
        }
Exemplo n.º 2
0
        private static async void RunningTask(IPauseToken token)
        {
            var i = 0;

            Thread.Sleep(1000);
            while (true)
            {
                Console.WriteLine(i++);
                await Task.Delay(10);

                await token.WaitWhilePausedAsync();
            }
        }