Пример #1
0
        public async Task <IEnumerable <Car> > AllCarsAsync()
        {
            List <Car> carsResult = new List <Car>();

            foreach (var uri in PayloadSources)
            {
                IEnumerable <Car> cars = await CarService.GetCarsAsync(uri);

                carsResult.AddRange(cars);
            }

            return(carsResult);
        }
Пример #2
0
        public async Task <IEnumerable <Car> > AllCarsInParallelNonBlockingAsync()
        {
            IEnumerable <Task <IEnumerable <Car> > > allTasks = PayloadSources.Select(uri => CarService.GetCarsAsync(uri));

            IEnumerable <Car>[] allResults = await Task.WhenAll(allTasks);

            return(allResults.SelectMany(cars => cars));
        }