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. mysql中exists、not exists的用法

    exists 关键字是判断是否存在的,存在则返回true,不存在则返回false, not exists则是不存在时返回true,存在返回false: 1. 最常用的if not  exists用法: ...

  2. 00002、div的文字垂直居中与背景的渐变

    1.div可以放多行的文字,当显示文字较少时,文字可垂直居中 text-align: center; display: table-cell; vertical-align: middle; text ...

  3. 【转载】CANoe 入门 Step by step系列(二)CAPL编程

    来源:http://www.cnblogs.com/dongdonghuihui/archive/2012/09/26/2704619.html CAPL就是Communication Applica ...

  4. nyoj_323:Drainage Ditches(网络流入门)

    题目链接 网络流入门@_@,此处本人用的刘汝佳的Dinic模板 #include<bits/stdc++.h> using namespace std; const int INF = 0 ...

  5. vue2中component父子组件传递数据props的使用

    子组件使用父亲传过来的数据,我们需要通过子组件的 props 选项. 组件实例的作用域是孤立的,不能在子组件的模板内直接引用父组件的数据.修改父亲传过来的props数据的时候 父亲必须传递对象,否则不 ...

  6. 自然饱和度(Vibrance)算法的模拟实现及其SSE优化(附源码,可作为SSE图像入门,Vibrance算法也可用于简单的肤色调整)。

    Vibrance这个单词搜索翻译一般振动,抖动或者是响亮.活力,但是官方的词汇里还从来未出现过自然饱和度这个词,也不知道当时的Adobe中文翻译人员怎么会这样处理.但是我们看看PS对这个功能的解释: ...

  7. 最近任务 && react文章列表

    最近任务 读书 数据分析 react深入学习 可视化大图 移动端入门 [React学习] 入门学习-文本渲染 http://www.cnblogs.com/huxiaoyun90/p/4783663. ...

  8. 花了一年时间完成的 在线G代码编辑,加工系统 G-Code Editor V1.0

    G代码是数控程序中的加工指令.一般都称为G指令.可以直接用来驱动机床,各种控制系统.是一种数控行业标准.传统的G代码编写以及编辑无法在线编辑,也不能实时看到g代码编辑的最后加工路径已经不能直接对编辑的 ...

  9. RSA简介(一)——数论原理

    RSA是最常用的非对称加密算法. 所谓非对称加密,就是说有两个密钥,一个密钥加密只可以用另外一个密钥解密,一般一个作为公钥,公开给所有人用来加密用,而另一个用来解密其他拥有公钥的加密结果,叫做私钥.另 ...

  10. 关于Django的理解

    Django的理解 Django的核心是中间件, 所有的请求和响应都会经过中间件 中间件是一个钩子框架, 它们可以介入请求的响应处理过程, 它用于在全局修改Django的输入和输出 Django有以下 ...