Threads inside a foreach loop in c#

前端 未结 8 1552
粉色の甜心
粉色の甜心 2020-12-31 23:52

Hai guys,

I had the following code to send different mails to differnt users in my asp.net web application

foreach (DataRow dataRow in dataTable.Rows         


        
8条回答
  •  甜味超标
    2020-12-31 23:56

    Perhaps would be more sensible to use the Thread Pool for that, or even Parallel Linq, which comes in .NET 4.0 (or in Parallel FX):

    dataTable.Rows.AsParallel().Select(a =>
    {
        //mail code
        return null;
    });
    

提交回复
热议问题