echo ""; echo ""; echo ""; echo ""; if(!is_admin){echo "";} » C#中简单的多线程调用 仲子说

2011-07-13

C#中简单的多线程调用

Posted in .NET at 10:41 Author:仲远

标签:

????????????????????????????????????????????????????????.NET Framewrok 4?????Parallel.For?Parallel.Foreach???????????????????????????????????

List<string> lines = GetLines(); //get the set of elements
Parallel.ForEach<string>(lines, line =>
{
string[] fields = line.Split(new char[] { ‘\t’ });
//Do something with the element: line
});

???????lines????????????list??????collection?Parallel.ForEach<string>????????string????????????????????????line???????{…}?????????????

???????????????????????list???????????Collections???thread-safe??????.Net 4.0 ?System.Collections.Concurrent Namespace??????????????????????? (?)?Parallel.For?Parallel.Foreach ??????

本文可以自由转载,转载时请保留全文并注明出处:
转载自仲子说 [ http://www.wangzhongyuan.com/ ]
原文链接:

Leave a Comment

*
To prove you're a person (not a spam script), type the security text shown in the picture. Click here to regenerate some new text.
Click to hear an audio file of the anti-spam word