List<Task> taskList = new List<Task>();

            // string currentNoStr = null; cannot define at here, we should define the copy in for loop, this is a  .NET FW bug for 4.0/4.5
// I am not sure whether this issue is fixed in latest version, below is the workaround
for (int currentNo = startPhaseNo; currentNo <= endPhaseNo; currentNo++)
{
string currentNoStr = currentNo.ToString();
taskList.Add(Task.Run(() =>
{
string result = GetLotteryByPhase(currentNoStr);
if (!string.IsNullOrEmpty(result))
{
resultDict.Add(currentNoStr, result);
}
})); if (currentNo % >= )
{
currentNo /= ;
currentNo++;
currentNo *= ;
continue;
}
}
await Task.WhenAll(taskList);
return resultDict;

How to execute tons of tasks parallelly with TPL method?的更多相关文章

  1. Why you should use async tasks in .NET 4.5 and Entity Framework 6

    Improve response times and handle more users with parallel processing Building a web application usi ...

  2. [转]How to: Execute Oracle Stored Procedures Returning RefCursors

    本文转自:http://www.telerik.com/help/openaccess-orm/openaccess-tasks-oracle-execute-sp-result-set.html I ...

  3. wesome-android

    awesome-android Introduction android libs from github System requirements Android Notice If the lib ...

  4. Windows Service--Write a Better Windows Service

    原文地址: http://visualstudiomagazine.com/Articles/2005/10/01/Write-a-Better-Windows-Service.aspx?Page=1 ...

  5. java多线程系类:JUC线程池:03之线程池原理(二)(转)

    概要 在前面一章"Java多线程系列--"JUC线程池"02之 线程池原理(一)"中介绍了线程池的数据结构,本章会通过分析线程池的源码,对线程池进行说明.内容包 ...

  6. Don't Block on Async Code【转】

    http://blog.stephencleary.com/2012/07/dont-block-on-async-code.html This is a problem that is brough ...

  7. Java多线程系列--“JUC线程池”03之 线程池原理(二)

    概要 在前面一章"Java多线程系列--“JUC线程池”02之 线程池原理(一)"中介绍了线程池的数据结构,本章会通过分析线程池的源码,对线程池进行说明.内容包括:线程池示例参考代 ...

  8. Sharepoint学习笔记—习题系列--70-576习题解析 -(Q16-Q18)

    Question 16 You are designing a SharePoint 2010 solution to manage statements of work. You need to d ...

  9. Java基础之-ExecutorService

    翻译javadoc系列文章之:ExecutorService /** * An {@link Executor} that provides methods to manage termination ...

随机推荐

  1. Python的元类

    1.用元类验证子类 每当我们定义新类的时候,元类就会运行雅正代码,以确保这个新类符合规定的规范. Python系统把子类的class语句处理完毕,就会调用元类的 __new__ 方法.元类可以通过 _ ...

  2. jsp: c:foreach 输出序号

    关键在于<c:forEach>的varStatus属性,具体代码如下: <table width="500" border="0" cells ...

  3. 关于SpringMVC中如何把查询数据全转成String类型

    之前,本想与客户商量做几张固定的报表予使用,结果发现客户每个月都需要各种各样的报表,所以我们做了个窗口用于直接执行SQL语句:数据量一开始并不是很大查询出来的数据较少(约1-6W左右),所以刚开始几个 ...

  4. nyoj_120: 校园网络

    题目链接 要加边使一个图成为一个强连通分量,只需加max(出度为0的点数,入度为0的点数)条边(可以不使用tarjan算法).题目数据有点弱,网上一些人所谓 结果 = 出度为0的点的数量+入度为0的点 ...

  5. linux基础(五)

    一.linux网络原理及基础设置 ifconfig 命令:显示所有正在启动的网卡的详细信息或设定系统中网卡的IP地址. [root@bogon ~]# ifconfig ens33: flags=41 ...

  6. bash脚本的特性01

    1.bash特性之多命令执行 read -p "please enter a passwd for $name ,[passwd]: " password [ -z "$ ...

  7. 手机摄像头扫描识别车牌号,移动端车牌识别sdk

    一.移动端车牌识别应用背景 (技术交流:18701686857  QQ:283870550) 随着经济水平的不断提高,汽车数量的不断激增为汽车管理带来了不小的难度.路边违章停车的现象越来越频繁.现在, ...

  8. 决策树(ID3 )原理及实现

    1.决策树原理 1.1.定义 分类决策树模型是一种描述对实例进行分类的树形结构.决策树由结点和有向边组成.结点有两种类型:内部节点和叶节点,内部节点表示一个特征或属性,叶节点表示一个类. 举一个通俗的 ...

  9. MySQL学习笔记(五):MySQL表级锁和行级锁

    一:概述 相对其他数据库而言,MySQL的锁机制比较简单,其最显著的特点是不同的存储引擎支持不同的锁机制.比如,MyISAM和MEMORY存储引擎采用的是表级锁(table-level locking ...

  10. JAVA二维数组的复制

    JAVA二维数组的复制 笔者今天做一道ccf题目时,遇到要将二维数组拷贝复制时,没有用常规的那种一个一个数的复制,用的是System.arraycopy()来进行复制,下面介绍这个函数的一些注意点: ...