循环并行执行

 

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();//对循环后的数据做处理

 

posted @   流年sugar  阅读(24)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 无需6万激活码!GitHub神秘组织3小时极速复刻Manus,手把手教你使用OpenManus搭建本
· C#/.NET/.NET Core优秀项目和框架2025年2月简报
· Manus爆火,是硬核还是营销?
· 终于写完轮子一部分:tcp代理 了,记录一下
· Qt个人项目总结 —— MySQL数据库查询与断言
点击右上角即可分享
微信分享提示