Beispiel #1
0
 private static async Task RunTelePrompter()
 {
     var config      = new TelePrompterConfig();
     var displayTask = ShowTelePrompter(config);
     var speedTask   = GetInput(config);
     await Task.WhenAny(displayTask, speedTask);
 }
Beispiel #2
0
        private static async Task ShowTelePrompter(TelePrompterConfig config)
        {
            var words = ReadFrom("sampleQuotes.txt");

            foreach (var word in words)
            {
                Console.Write(word);
                if (!string.IsNullOrWhiteSpace(word))
                {
                    await Task.Delay(config.DelayInMilliseconds);
                }
            }
            config.SetDone();
        }
Beispiel #3
0
 private static async Task GetInput(TelePrompterConfig config)
 {
     Action work = () =>
     {
         do
         {
             var key = Console.ReadKey(true);
             if (key.KeyChar == '>')
             {
                 config.UpdateDelay(-10);
             }
             else if (key.KeyChar == '<')
             {
                 config.UpdateDelay(10);
             }
         } while (!config.Done);
     };
     await Task.Run(work);
 }