I have the following code:
我有以下代码:
innerExceptions = dbconnByServer
.AsParallel()
.WithDegreeOfParallelism(dbconnByServer.Count)
// A stream of groups of server connections proceeding in parallel per server
.Select(dbconns => dbconns.Select(dbconn => m_sqlUtilProvider.Get(dbconn)))
// A stream of groups of SqlUtil objects proceeding in parallel per server
.Select(sqlUtils => GetTaskException(sqlUtils
// Aggregate SqlUtil objects to form a single Task which runs the SQL asynchronously for the first SqlUtil, then upon completion
// for the next SqlUtil and so long until all the SqlUtil objects are processed asynchronously one after another.
.Aggregate<ISqlUtil, Task>(null, (res, sqlUtil) =>
{
if (res == null)
{
return sqlUtil.ExecuteSqlAsync(SQL, parameters);
}
return res.ContinueWith(_ => sqlUtil.ExecuteSqlAsync(SQL, parameters)).Unwrap();
})))
.Where(e => e != null)
.ToList();
innerExc