Esempio n. 1
0
 private static async Task RunTeleprompter()
 {
     var config      = new TelePrompterConfig();
     var displayTask = ShowTeleprompter(config);
     var speedTask   = GetInput(config);
     await Task.WhenAny(displayTask, speedTask);
 }
Esempio n. 2
0
 private static async Task GetInput(TelePrompterConfig config)
 {
     // var delay = 200;
     Action work = () =>
     {
         do
         {
             var key = Console.ReadKey(true);
             if (key.KeyChar == '>')
             {
                 config.UpdateDelay(-10);
             }
             // {
             //     delay -= 10;
             // }
             else if (key.KeyChar == '<')
             {
                 config.UpdateDelay(10);
             }
             // {
             //     delay += 10;
             // }
         } while (!config.Done);
     };
     await Task.Run(work);
 }
Esempio n. 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);
                    }
                    else if (key.KeyChar == 'X' || key.KeyChar == 'x')
                    {
                        config.SetDone();
                    }
                } while (!config.Done);
            };

            await Task.Run(work);
        }
Esempio n. 4
0
        /*added async modifier to the method signature */
        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();
            // Synchronously waiting on a task is an
            // anti-pattern. This will get fixed in later
            // steps.
            // var words = ReadFrom("sampleQuotes.txt");
            // foreach (var line in words)
            // {
            //     Console.Write(line);
            //     if (!string.IsNullOrWhiteSpace(line))
            //     {
            //         await Task.Delay(200);
            //     }
            // }
        }
Esempio n. 5
0
        private static async Task RunTeleprompter()
        {
            var config = new TelePrompterConfig();
            var displayTask = ShowTeleprompter(config);

            var speedTask = GetInput(config);
            await Task.WhenAny(displayTask, speedTask);
        }
Esempio n. 6
0
        private static async Task RunTeleprompter()
        {
            var config      = new TelePrompterConfig();
            var displayTask = ShowTeleprompter(config);

            var speedTask = GetInput(config);
            // creates a Task that finishes as soon as any of the tasks in its argument
            // list completes
            await Task.WhenAny(displayTask, speedTask);
        }
Esempio n. 7
0
        private static async Task RunTeleprompter()
        {
            var config      = new TelePrompterConfig();
            var displayTask = ShowTeleprompter(config);

            var speedTask = GetInput(config);
            await Task.WhenAny(displayTask, speedTask);

            /*Finishes as soon as any of the tasks in the argument list is completed */
        }
Esempio n. 8
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);
                }
            }
        }
Esempio n. 9
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();
 }
Esempio n. 10
0
        private static async Task ShowTeleprompter(TelePrompterConfig config)
        {
            var words = ReadFrom(@"C:\Users\Larri\Programming\newApp\Quotes.txt"); // Read the Quotes.

            foreach (var word in words)                                            // Loop through the words from the text.
            {
                Console.Write(word);                                               // Print out word
                if (!string.IsNullOrWhiteSpace(word))                              // If not reached EOF
                {
                    await Task.Delay(config.DelayInMilliseconds);                  // Delay
                }
            }
            config.SetDone();   // Done flag is True.
        }
Esempio n. 11
0
        private static async Task showTeleprompter(TelePrompterConfig config)
        {
            var words = ReadFrom(@"C: \Users\Larri\source\repos\Console_App_1\Console_App_1\sampleQuotes.txt");

            foreach (var word in words)
            {
                Console.Write(word);
                if (!string.IsNullOrWhiteSpace(word))
                {
                    await Task.Delay(config.DelayInMilliseconds);
                }
            }
            config.SetDone();
        }
Esempio n. 12
0
        public static async Task ShowTeleprompter(TelePrompterConfig config)
        {
            var lines = ReadFrom("sampleQuotes.txt");

            foreach (var line in lines)
            {
                Console.Write(line);
                if (!string.IsNullOrWhiteSpace(line))
                {
                    await Task.Delay(config.DelayInMilliseconds);
                }
            }
            config.SetDone();
        }
Esempio n. 13
0
        private static async Task ShowTeleprompter(TelePrompterConfig config)
        {
            var wordChunks = ReadFrom("sampleQuotes.txt");  // wordChunksOrNull

            foreach (var wordChunk in wordChunks)
            {
                Console.Write(wordChunk);
                if (!string.IsNullOrWhiteSpace(wordChunk))
                {
                    await Task.Delay(config.DelayInMilliseconds);
                }
            }
            config.SetDone();
        }
Esempio n. 14
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);
 }
Esempio n. 15
0
        private static async Task ShowTeleprompter(TelePrompterConfig config)
        {
            IEnumerable <string> words = ReadFrom("sampleQuotes.txt");

            foreach (string line in words)
            {
                // Console.Write(config.DelayInMilliseconds);
                Console.Write(line);
                if (!string.IsNullOrWhiteSpace(line))
                {
                    await Task.Delay(config.DelayInMilliseconds);
                }
            }
            config.SetDone();
        }
Esempio n. 16
0
        private static async Task ShowTeleprompter(TelePrompterConfig config)
        {
            var words = ReadFrom("sampleQuotes.txt");

            foreach (var word in words)
            {
                Console.Write(word);

                // if the current word is NOT null or whitespace...
                if (!string.IsNullOrWhiteSpace(word))
                {
                    await Task.Delay(config.DelayInMilliseconds);
                }
            }

            config.SetDone();
        }
Esempio n. 17
0
 static async Task GetInput(TelePrompterConfig config)
 {
     Action work = () =>
     {
         do
         {
             var key = Console.ReadKey(true);
             if (key.KeyChar == 'l')                   //delays up the process of echo
             {
                 config.UpdateDelay(-10);
             }
             else if (key.KeyChar == 'g')              // speeds up the process
             {
                 config.UpdateDelay(10);
             }
             else if (key.KeyChar == 'X' || key.KeyChar == 'x')   // stops the process
             {
                 config.SetDone();
             }
         } while (!config.Done);
     };
     await Task.Run(work);
 }
Esempio n. 18
0
 private static async Task GetInput(TelePrompterConfig config)
 {
     Action work = () =>
     {
         do      // Read keysrtokes.
         {
             var key = Console.ReadKey(true);
             if (key.KeyChar == '>') // Increase speed
             {
                 config.UpdateDelay(-10);
             }
             else if (key.KeyChar == '<')    // Decrease speed
             {
                 config.UpdateDelay(10);
             }
             else if (key.KeyChar == 'X' || key.KeyChar == 'x')  // Finish reading file
             {
                 config.SetDone();
             }
         } while (!config.Done); // Wait until finished
     };
     await Task.Run(work);
 }