循环并行执行
1 ConcurrentBag<PackageCheckDataDownLoadDto> pList = new ConcurrentBag<PackageCheckDataDownLoadDto>();//保证线程安全 2 Parallel.ForEach(list, new ParallelOptions { MaxDegreeOfParallelism = Environment.ProcessorCount }, (item, ParallelLoopState, index) => 3 { 4 var base64 = GetImageBase64(path + @"\GY01\20220509\1.jpg"); 5 item.PicturePath = string.IsNullOrWhiteSpace(base64) ? item.PicturePath : base64; 6 }); 7 var result = pList.OrderBy(r => r.SortLine).ToList();//对循环后的数据做处理