0
//get rows from db

foreach(DataRow r in rows)
{
//connect to some other database
//update some record in datatable
//insert record into datatable
//etc...
//...
}

如何使用多线程机制来重写上面的代码,然后我们可以从多服务器中受益?

4

1 回答 1

4

也许这会有所帮助

IEnumerable<DataRow> items = ...

Parallel.ForEach(items, item => {
   ...
});

Parallel.ForEach

于 2012-11-13T14:25:50.000 回答