public async Task <Result <bool> > ProcessList() { Result <bool> result = new Result <bool>(); return(await Task.Run(() => { try { Parallel.ForEach(CollectionEstate, item => { try { var a = _repositoryRosreestr.GetRealEstate(item.Id); if (a != null) { item.Estate = a; } else { item.Estate = new ErrorEstate("Ничего не найдено"); } } catch (Exception ex) { item.Estate = new ErrorEstate(ex.Message); } }); var file = _createFile.CreateXlsx(ServiceConvert.ConvertCollectionEntityEstate(CollectionEstate), _fileName); _createFile.CreateCsv(ServiceConvert.ConvertCollectionErrorEntityEstate(CollectionEstate), _createFile.CreateErrorName(_fileName)); _createFile.OpenFolderFile(file); result.Item = true; } catch (Exception ex) { result.ErrorResult = new ErrorResult(ex.Message, EnumTypeError.ErrorSite); } return result; })); }