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的更多相关文章

  1. C++多线程开发之actor model

    最近想把写过的一个多线程程序整理一下,这个程序主要特点是有一系列的互相之间有依赖关系的task.于是在网上找相关类库 1,一类是简单的线程池了,这也是原本俺的做法.之前使用的是手工调度,代码实现的很蛋 ...

  2. .NET “底层”异步编程模式——异步编程模型(Asynchronous Programming Model,APM)

    本文内容 异步编程类型 异步编程模型(APM) 参考资料 首先澄清,异步编程模式(Asynchronous Programming Patterns)与异步编程模型(Asynchronous Prog ...

  3. PatentTips - Heterogeneous Parallel Primitives Programming Model

    BACKGROUND 1. Field of the Invention The present invention relates generally to a programming model ...

  4. Udacity并行计算课程笔记-The GPU Programming Model

    一.传统的提高计算速度的方法 faster clocks (设置更快的时钟) more work over per clock cycle(每个时钟周期做更多的工作) more processors( ...

  5. HttpWebRequest - Asynchronous Programming Model/Task.Factory.FromAsyc

    Posted by Shiv Kumar on 23rd February, 2011 The Asynchronous Programming Model (or APM) has been aro ...

  6. 【Udacity并行计算课程笔记】- lesson 1 The GPU Programming Model

    一.传统的提高计算速度的方法 faster clocks (设置更快的时钟) more work over per clock cycle(每个时钟周期做更多的工作) more processors( ...

  7. Programming Model

    上级:https://www.cnblogs.com/hackerxiaoyon/p/12747387.html Dataflow Programming Model 数据流的开发模型 Levels ...

  8. Async Programming All in One

    Async Programming All in One Async & Await Frontend (async () => { const url = "https:// ...

  9. 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 ...

  10. Scalaz(54)- scalaz-stream: 函数式多线程编程模式-Free Streaming Programming Model

    长久以来,函数式编程模式都被认为是一种学术研究用或教学实验用的编程模式.直到近几年由于大数据和多核CPU的兴起造成了函数式编程模式在一些实际大型应用中的出现,这才逐渐改变了人们对函数式编程无用论的观点 ...

随机推荐

  1. mvn clean 后 mvn package失败

    项目完全没有问题,就是mvn clean package 失败,或者打包成功后发布项目无法启动. 很可能的原因是,clean后一些需要编译生成的文件还没有生成,直接package会出错,或者packa ...

  2. html中checkbox自定义样式(css版本)

    <span class="choose"><input type="checkbox" class="input_check&quo ...

  3. selenium操作下拉选和网页提示框

    import time from selenium import webdriver from selenium.webdriver.support.select import Select#处理下拉 ...

  4. asp.net mvc + vue.js + axios.js

    1.新建一个 MVC 应用程序 2.右键解决方案 添加VUE 3.搜索vue 1.安装axios.js ,用于数据请求,get , post axios

  5. sql 查询 某字段是否重复

    select count(*) from ( select * from 客户 )C GROUP BY 客户编码 select * from ( select count(*)num from ( s ...

  6. TTTTTTTTTTTTTT POJ 3678 与或异或 2-SAT+强连通 模板题

    Katu Puzzle Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 9129 Accepted: 3391 Descripti ...

  7. sh_03_程序计数

    sh_03_程序计数 # 打印 5 遍 Hello Python # 1. 定义一个整数变量,记录循环次数 i = 0 # 2. 开始循环 while i < 3: # 1> 希望在循环内 ...

  8. maven工程项目与项目之间的依赖方式

    首先看一下项目结构: ​ 1.需要在父工程中把子工程为坐标引进来,同时标注父工程为pom工程: ​ 2.同时在父工程中把子工程当作一个模块引进来 ​ 3.需要在每一个子项目中通过parent标签,标注 ...

  9. [LeetCode]-DataBase-Trips and Users

    The Trips table holds all taxi trips. Each trip has a unique Id, while Client_Id and Driver_Id are b ...

  10. Visual Studio 2019 企业版 注册码 百度云下载

    微软官网下载地址:https://visualstudio.microsoft.com/zh-hans/downloads/ Key: Visual Studio 2019 Enterprise 企业 ...