protected void Main()
{
//首先定义一个方法的封装..后边的LongTimeMethod是被封装的方法..
Func<int> longTimeAction = new Func<int>(LongTimeMethod);
//定义一个异步操作.. asynResult
//用上边的longTimeAction封装 来开启这个异步操作.. IAsyncResult asynResult = longTimeAction.BeginInvoke(null, null);
//在上边的开启异步操作后..程序会另外启动一个线程来执行前边的封装方法..这个方法是委托给这个新线程的
//得到了异步请求的结果..返回给 ret
int ret = longTimeAction.EndInvoke(asynResult);
} int LongTimeMethod()
{
return ;
}
        protected void Main ()
{
//首先定义一个方法的封装..后边的LongTimeMethod是被封装的方法..
Func<int> longTimeAction = new Func<int>(LongTimeMethod);
//定义一个异步操作.. asynResult
//用上边的longTimeAction封装 来开启这个异步操作.. int ss=;
IAsyncResult asynResult = longTimeAction.BeginInvoke((result) => { ss = longTimeAction.EndInvoke(result); }, null);
//在上边的开启异步操作后..程序会另外启动一个线程来执行前边的封装方法..这个方法是委托给这个新线程的
//得到了异步请求的结果..返回给 ss
} int LongTimeMethod()
{
return ;
}

.net3.5后新增的 BeginInvoke EndInvoke 异步操作的更多相关文章

  1. 多线程 异步 beginInvoke EndInvoke 使用

    有许多耗时操作时,还要响应用户操作.这时候就需要用其他线程或者异步来搞.本来是改造公司的日志组件.因为多上了个国外大区的业务到来本系统来.这个系统其他地方都好就是日志,动不动就要死给我们看.有时候寻找 ...

  2. C# 对委托的BeginInvoke,EndInvoke 及Control 的BeginInvoke,EndInvoke 的理解

    using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; usin ...

  3. 转:C# 对委托的BeginInvoke,EndInvoke 及Control 的BeginInvoke,EndInvoke 的理解

    转载自:http://www.cnblogs.com/easyfrog/p/3141269.html using System; using System.Collections.Generic; u ...

  4. 用python+selenium登录cnblog后新增文章后再次删除该文章

    目的:登录cnblog后新增文章后再次删除该文章并验证 代码如下: #coding: utf-8 from selenium import webdriver from time import sle ...

  5. C#如何使用异步编程【BeginInvoke/EndInvoke】

    怎么使用异步,就是用委托进行处理,如果委托对象在调用列表中只有一个方法,它就可以异步执行这个方法.委托类有两个方法,叫做BeginInvoke和EndInvoke,它们是用来异步执行使用. 异步有三种 ...

  6. C#_delegate - 异步调用实例 BeginInvoke EndInvoke event

    using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.T ...

  7. 织梦(dedecms)如何清空全部文章和删除后新增文章id号归1的方法

    很多朋友在使用织梦程序做网站的过程中,难免需要添加一些测试文章用于测试网站功能模板等,还有些人朋友网站改版需要变更内容的时候,面对着众多的老文章后总是一筹莫展! 由于织梦后台并不自带一键删除整站文章的 ...

  8. c#委托中的同步和异步方法即BeginInvoke和EndInvoke

    学习多线程之前我们先了解一下电脑的一些概念,比如进程,线程,这个参考https://www.cnblogs.com/loverwangshan/p/10409755.html 这篇文章.今天我们接着来 ...

  9. 异步编程(AsyncCallback委托,IAsyncResult接口,BeginInvoke方法,EndInvoke方法的使用小总结)

    http://www.cnblogs.com/panjun-Donet/archive/2009/03/03/1284700.html 让我们来看看同步异步的区别: 同步方法调用在程序继续执行之前需要 ...

随机推荐

  1. Handler消息机制与Binder IPC机制完全解析

    1.Handler消息机制 序列 文章 0 Android消息机制-Handler(framework篇) 1 Android消息机制-Handler(native篇) 2 Android消息机制-H ...

  2. 如何破解Excel文档的编辑密码

    对于Excel文档我们不仅可以设置打开密码,还可以设置几天几种密码,比如编辑密码.编辑密码又称写保护密码,是一种可以限制编辑权限的密码.如果我们在日常工作中发现自己忘记了excel编辑密码的话,那就需 ...

  3. Web前端性能优化教程04:压缩组件

    本文是Web前端性能优化系列文章中的第四篇,主要讲述内容:压缩组件.完整教程可查看:Web前端性能优化 基础知识 gzip编码:gzip是GUNzip的缩写,是使用无损压缩算法的一种,最早是用于Uni ...

  4. Java中Comparable和Comparator区别小结

    一.Comparable简介 Comparable是排序接口.若一个类实现了Comparable接口,就意味着该类支持排序.实现了Comparable接口的类的对象的列表或数组可以通过Collecti ...

  5. 67.Android中的数据存储总结

    转载:http://mp.weixin.qq.com/s?__biz=MzIzMjE1Njg4Mw==&mid=2650117688&idx=1&sn=d6c73f9f04d0 ...

  6. 【poj3122】 Pie

    http://poj.org/problem?id=3122 (题目链接) 题意 给出N个pie的半径和F个friend,每个friend得到的pie必须一样,求每个人能得到的pie的最大大小. so ...

  7. SVN中(trunk tags branches)的使用理解

    trunk--主干(永远都是最新的,每发布一个版本会在tags和branches上进行分支) tags-标签(只读,用于存放发布后的文件冻结,以及对应发布后版本的源文件:可以是来自主干或者分支的发布: ...

  8. Writing a simple Lexer in PHP/C++/Java

    catalog . Comparison of parser generators . Writing a simple lexer in PHP . phc . JLexPHP: A PHP Lex ...

  9. Ubuntu 使用笔记

    持续更新 从前使用sudo apt update更新时, 发现软件源是cn.archive.ubuntu.com. 最近在system setting 中将软件源改成了archive.ubuntu.c ...

  10. hihoCoder #1379 Emulator

    hihoCoder Challenge 23, Prob. A 时间限制:5000ms 单点时限:1000ms 内存限制:256MB 描述 有一个\(n\)个点的无向正权图\(G\),这个图是连通的, ...