Exemplo n.º 1
0
        public async Task <ViewResult> Asynchronous()
        {
            //Asynchronous methods
            long?traditionalLength = await MyAsyncMethods.TraditionalGetPageLength();

            long?simplyLength = await MyAsyncMethods.SimplifyGetPageLength();

            Console.WriteLine($"traditionalLength:{traditionalLength}, simplyLength:{simplyLength}");

            //Asynchronous Enumerable
            List <String> output = new List <string>();

            await foreach (long?length in MyAsyncMethods.GetPageLength(output, "apress.com", "microsoft.com", "amazon.com"))
            {
                output.Add($"Page length : {length}");
            }
            foreach (string item in output)
            {
                Console.WriteLine(item);
            }
            return(View(new string[] { $"traditionalLength:{traditionalLength}, simplyLength:{simplyLength}" }));
        }