示例#1
0
        public async Task <IEnumerable <HealthCheck> > Get(int id)
        {
            try
            {
                FileHelper        fh         = new FileHelper();
                HealthCheckHelper helthCheck = new HealthCheckHelper();

                var urlsListTasks = await fh.GetUrlsFromFilesAsync();

                var taskList = new List <Task <HealthCheck> >();
                foreach (var myRequest in urlsListTasks)
                {
                    int counter = 0;
                    // by virtue of not awaiting each call, you've already acheived parallelism
                    taskList.Add(helthCheck.HitEndpointAsync(myRequest, ++counter));
                }



                //var resultList =  await helthCheck.HitEndpointAsync(urlsListTasks);
                var result = await Task.WhenAll(taskList.ToList());

                return(result);
            }
            catch (Exception)
            {
                return(new List <HealthCheck>());
            }
        }
示例#2
0
        public async Task <IEnumerable <HealthCheck> > Get()
        {
            try
            {
                FileHelper        fh         = new FileHelper();
                HealthCheckHelper helthCheck = new HealthCheckHelper();

                var urlsListTasks = await fh.GetUrlsFromFilesAsync();


                //var resultList =  await helthCheck.HitEndpointAsync(urlsListTasks);
                var result = await helthCheck.HitEndpointAsync(urlsListTasks);

                return(result);
            }
            catch (Exception)
            {
                return(new List <HealthCheck>());
            }
        }