Example #1
0
        private static async Task RunTeleprompter()
        {
            var config      = new TelePrompterConfig();
            var displayTask = ShowTeleprompter(config);

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

            foreach (var line in words)
            {
                Console.Write(line);
                if (!string.IsNullOrWhiteSpace(line))
                {
                    await Task.Delay(config.DelayInMilliseconds);
                }
            }
            config.SetDone();
        }
Example #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);
 }