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. js实现图片旋转、模板文件查看图片大图之记录篇[二]

    一个小小的前端需求送给大家,使用js实现图片旋转,并且点击图片能够实现规定格式的大图. 主要使用的是jQuery的delegate()方法实现图片旋转,该方法主要的功能就是给某个组件绑定一个或一组事件 ...

  2. Html5元素布局

    本教程十分简单,适合新手(因为我也是新手).本教程参考了"菜鸟教程". 笔者希望做到元素相对于浏览器的角落布局,即九个典型位置: 这个理念其实和UE4中的UMG锚定一样.Html5 ...

  3. 实时音视频互动系列(上):又拍云UTUN网络详解

    如何定义实时音视频互动, 延迟 400ms 内才能无异步感 实时音视频互动如果存在1秒左右的延时会给交流者带来异步感,必须将视频播放延迟限制在400ms以内,才能给用户较好的交互体验. 当延迟控制在4 ...

  4. Python--my first try!

    我所用的编译器是:Python 3.6.0 我之所以在一开始就说我的编译器是因为不同的编译器,不同的版本在代码的写法上会有一些区别! 比如:在我所用的版本3中print的用法是Print (" ...

  5. css 子div自适应父div高度

    <div class="out"> <div class="a"></div> <div class="b& ...

  6. CloseHandle 函数--关闭一个句柄

    CloseHandle函数 来源:https://msdn.microsoft.com/en-us/library/windows/desktop/ms724211(v=vs.85).aspx 作用 ...

  7. IBATIS动态SQL(1)

    转:IBATIS动态SQL 直接使用JDBC一个非常普遍的问题就是动态SQL.使用参数值.参数本身和数据列都是动态SQL,通常是非常困难的.典型的解决办法就是用上一堆的IF-ELSE条件语句和一连串的 ...

  8. 微信小程序(一)基本知识初识别

    最近微信圈里小程序很火的样子,以前小程序刚开始的时候研究了一下,多日没关注发现一些东西都淡忘了,最后决定还是记录下来的好. 毕竟好记星比不上烂笔头嘛~ 另外有想学习小程序的同学,也可以参考下,当然如果 ...

  9. 【PHP】基础学习

    摘要: 基础知识回顾 1)数组 2)字符串 3)时间 一.数组 1.1 数组分类索引数组:常规数组关联数组:键值对数组 二.字符串 2.1 定义字符串heredoc语法结构定义的字符串:$hello ...

  10. CentOS 访问 Windows 共享目录

    起因 由于公司的网络切换后,将所有的服务器都切换到了指定的网段(工作电脑在一个网络,服务器在另一个网络:这样一来,不同部门的 work stations 可以彼此访问,不同部门的服务器(servers ...