Parallel for-each loops in .NET C# z

  • An IEnumerable object
  • An Action of T which is used to process each item in the list
List<string> dataList = new List<string> 
{
         "this", "is", "random", "sentence", "hello", "goodbye"
};
 
Parallel.ForEach(dataList, item =>
{
    Console.WriteLine("Item {0} has {1} characters",
        item, item.Length);
});

 

posted on 2014-05-21 22:51  武胜-阿伟  阅读(230)  评论(0编辑  收藏  举报