多线程17-Async Programming Model
class Program
{
private delegate string RunOnThreadPool(out int threadId);
private static void Callback(IAsyncResult ar)
{
Console.WriteLine("Starting a callback");
Console.WriteLine("State passed to a callback:{0}", ar.AsyncState);
Console.WriteLine("Is Thread Polll Thread={0}", Thread.CurrentThread.IsThreadPoolThread);
Console.WriteLine("Thread pool worker thread id :{0}", Thread.CurrentThread.ManagedThreadId);
}
private static string Test(out int ThreadId)
{
Console.WriteLine("Starting ....");
Console.WriteLine("Is thread pool thread:{0}", Thread.CurrentThread.IsThreadPoolThread);
Thread.Sleep();
ThreadId = Thread.CurrentThread.ManagedThreadId;
return string.Format("Thread pool worker therad id was ={0}", ThreadId);
}
static void Main()
{
int threadId = ;
RunOnThreadPool poolDelegate = Test;
var t = new Thread(() => Test(out threadId));
t.Start();
t.Join();
Console.WriteLine("Thread id:{0}", threadId);
IAsyncResult r = poolDelegate.BeginInvoke(out threadId, Callback, "a delegae asyncResult call");
string result = poolDelegate.EndInvoke(out threadId, r);
Console.WriteLine("Thread pool worker thread id:{0}", threadId);
Console.WriteLine(result);
Thread.Sleep(TimeSpan.FromSeconds());
}
}
多线程17-Async Programming Model的更多相关文章
- C++多线程开发之actor model
最近想把写过的一个多线程程序整理一下,这个程序主要特点是有一系列的互相之间有依赖关系的task.于是在网上找相关类库 1,一类是简单的线程池了,这也是原本俺的做法.之前使用的是手工调度,代码实现的很蛋 ...
- .NET “底层”异步编程模式——异步编程模型(Asynchronous Programming Model,APM)
本文内容 异步编程类型 异步编程模型(APM) 参考资料 首先澄清,异步编程模式(Asynchronous Programming Patterns)与异步编程模型(Asynchronous Prog ...
- PatentTips - Heterogeneous Parallel Primitives Programming Model
BACKGROUND 1. Field of the Invention The present invention relates generally to a programming model ...
- Udacity并行计算课程笔记-The GPU Programming Model
一.传统的提高计算速度的方法 faster clocks (设置更快的时钟) more work over per clock cycle(每个时钟周期做更多的工作) more processors( ...
- HttpWebRequest - Asynchronous Programming Model/Task.Factory.FromAsyc
Posted by Shiv Kumar on 23rd February, 2011 The Asynchronous Programming Model (or APM) has been aro ...
- 【Udacity并行计算课程笔记】- lesson 1 The GPU Programming Model
一.传统的提高计算速度的方法 faster clocks (设置更快的时钟) more work over per clock cycle(每个时钟周期做更多的工作) more processors( ...
- Programming Model
上级:https://www.cnblogs.com/hackerxiaoyon/p/12747387.html Dataflow Programming Model 数据流的开发模型 Levels ...
- Async Programming All in One
Async Programming All in One Async & Await Frontend (async () => { const url = "https:// ...
- C#的多线程——使用async和await来完成异步编程(Asynchronous Programming with async and await)
https://msdn.microsoft.com/zh-cn/library/mt674882.aspx 侵删 更新于:2015年6月20日 欲获得最新的Visual Studio 2017 RC ...
- Scalaz(54)- scalaz-stream: 函数式多线程编程模式-Free Streaming Programming Model
长久以来,函数式编程模式都被认为是一种学术研究用或教学实验用的编程模式.直到近几年由于大数据和多核CPU的兴起造成了函数式编程模式在一些实际大型应用中的出现,这才逐渐改变了人们对函数式编程无用论的观点 ...
随机推荐
- DevExpress Winforms Controls:安装使用系统要求文档
[DevExpress WinForms v19.1下载] 本文档包含了有关安装和使用DevExpress WinForms控件的系统要求信息. .NET Framework 下图展示了支持的.NET ...
- CentOS源码编译安装MySQL 5.5.15
CentOS源码编译安装MySQL 5.5.15 文章目录 [隐藏] 安装编译工具 下载源码 安装cmake和bison 编译安装MySQL 一些相关设置 安装编译工具 yum install g ...
- 基于Ubuntu 搭建 WordPress 个人博客 - 开发者实验室 - 腾讯云
1.准备 LAMP 环境 安装 Apache2 在终端输入该命令 ,使用 apt-get 安装 Apache2: sudo apt-get install apache2 -y 安装好后,您可以通过访 ...
- aircrack-wifi密码破解
暴力破解wifi密码尝试 打开网卡监听模式 监听设置结果 扫描wifi 打开网卡监听模式 打开终端,用 airmon-ng 命令查看 root@kali:~/capture# airmon-ng PH ...
- web项目重启命令
jps -lvm|grep "young_rd_10004" | awk '{print $1}'|xargs kill -9; sleep 3; /home/web_server ...
- 【BZOJ3876】 [Ahoi2014]支线剧情
Description [故事背景] 宅男JYY非常喜欢玩RPG游戏,比如仙剑,轩辕剑等等.不过JYY喜欢的并不是战斗场景,而是类似电视剧一般的充满恩怨情仇的剧情.这些游戏往往 都有很多的支线剧情,现 ...
- sh_04_累加求和
sh_04_累加求和 # 计算 0 ~ 100 之间所有数字的累计求和结果 # 0. 定义最终结果的变量 result = 0 # 1. 定义一个整数的变量记录循环的次数 i = 0 # 2. 开始循 ...
- vue-cli 构建的 Vue 项目用 localhost 加 端口 能访问,但是切换到 ip 加 端口 就不能访问
问题出在 webpack 的配置 在 config 文件夹下, 找到 index.js 目录, 找到如下代码 host: 'localhost', // can be overwritten by p ...
- python-opencv中的cv2.inRange函数
本次目标是将一副图像从rgb颜色空间转换到hsv颜色空间,颜色去除白色背景部分 具体就调用了cv2的两个函数,一个是rgb转hsv的函数 具体用法 hsv = cv2.cvtColor(rgb_ima ...
- python-opencv学习第一章
一.opencv读入图像 retval=cv2.imread(文件名[,显示控制参数]) 常用三个参数如下 CV. IMREAD_UNCHANGED 不改变原先什么样子现在就是什么样子 CV. IMR ...