LINQ equivalent of foreach for IEnumerable

后端 未结 22 2299
夕颜
夕颜 2020-11-21 22:54

I\'d like to do the equivalent of the following in LINQ, but I can\'t figure out how:

IEnumerable items = GetItems();
items.ForEach(i => i.DoS         


        
22条回答
  •  走了就别回头了
    2020-11-21 23:34

    Now we have the option of...

            ParallelOptions parallelOptions = new ParallelOptions();
            parallelOptions.MaxDegreeOfParallelism = 4;
    #if DEBUG
            parallelOptions.MaxDegreeOfParallelism = 1;
    #endif
            Parallel.ForEach(bookIdList, parallelOptions, bookID => UpdateStockCount(bookID));
    

    Of course, this opens up a whole new can of threadworms.

    ps (Sorry about the fonts, it's what the system decided)

提交回复
热议问题