Example #1
0
        static async Task Main(string[] args)
        {
            await AsyncAwait();
            await FullAsync();

            Synchronous();

            Mapper.AdapterMapper        mapper = new Mapper.AdapterMapper();
            Mapper.Models.Adapter.Users user   = mapper.GetUser(3);
            Console.WriteLine($"User with id {user.Id} is {user.Name}.");

            user = await mapper.GetUserAsync(3);

            Console.WriteLine($"Confirming information, user with id {user.Id} is {user.Name}.");
        }
Example #2
0
        /// <summary>
        /// Queries for TEST_COUNT lists of users forcing await for each request.
        /// </summary>
        private static async Task AsyncAwait()
        {
            Mapper.AdapterMapper mapper = new Mapper.AdapterMapper();
            Mapper.Models.Adapter.UsersCollection[] usersCollection = new Mapper.Models.Adapter.UsersCollection[TEST_COUNT];

            Stopwatch stopWatch = Stopwatch.StartNew();

            for (int index = 0; index < TEST_COUNT; index++)
            {
                usersCollection[index] = await mapper.GetUsersAsync();
            }
            stopWatch.Stop();

            Console.WriteLine($"Async/Await: Retrieved {usersCollection.Select(x => x.Count).Sum()} elements in {stopWatch.ElapsedMilliseconds} ms.");
            DumpUsers(usersCollection);
        }