public IActionResult GetStatuses(List <long> resourceIds) { var resourceAndStatus = new ConcurrentDictionary <long, CloudFuncs.Common.Models.ResourceState>(); Parallel.ForEach(resourceIds, async id => { var cloudResource = await _cloudStorageService.GetCloudResourceById(id); if (cloudResource != null) { resourceAndStatus.TryAdd(id, cloudResource.State); } }); return(Ok(resourceAndStatus.Select(x => new ResourceStatusModel { ResourceId = x.Key, Status = x.Value.ToString() }))); }