Esempio n. 1
0
        private static async Task RunTeleprompter()
        {
            var config      = new TelePromterConfig();
            var displayTask = ShowTeleprompter(config);

            var speedTask = GetInput(config);
            await Task.WhenAny(displayTask, speedTask);
        }
Esempio n. 2
0
        private static async Task ShowTeleprompter(TelePromterConfig config)
        {
            var lines = ReadFrom("sampleQuotes.txt");

            foreach (var item in lines)
            {
                Console.Write(item);
                if (!string.IsNullOrWhiteSpace(item))
                {
                    await Task.Delay(config.DelayInMilliseconds);
                }
            }
            config.SetDone();
        }
Esempio n. 3
0
 private static async Task GetInput(TelePromterConfig config)
 {
     Action work = () =>
     {
         do
         {
             var key = Console.ReadKey(true);
             if (key.KeyChar == '>')
             {
                 config.UpdateDelay(-10);
             }
             else if (key.KeyChar == '<')
             {
                 config.UpdateDelay(10);
             }
             else if (key.KeyChar == 'X' || key.KeyChar == 'x')
             {
                 config.SetDone();
             }
         } while (!config.Done);
     };
     await Task.Run(work);
 }