using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks; namespace WindowsFormsApplication1
{
public class delegateclass
{
private delegate int Dothread();
static Dothread dothread = new Dothread(work); public static void start()
{
AsyncCallback backCall = new AsyncCallback(backcall); dothread.BeginInvoke(backCall, "我是异步调用的parameter");//第一个参数是调用work方法的参数,第二个是回调函数,第三个是需要传到回调函数里的参数可以是Object类型
}
/// <summary>
///这个是委托调用程序
/// </summary>
private static int work()
{
System.Windows.Forms.MessageBox.Show("我是委托调用程序");
return ; }
/// <summary>
/// 回调函数
/// </summary>
/// <param name="parameter"></param>
/// <returns></returns>
private static int backcall(int parameter)
{
System.Windows.Forms.MessageBox.Show("这是一个回调函数");
return ; }
private static void backcall(IAsyncResult parameter)
{
int result=dothread.EndInvoke(parameter);
System.Windows.Forms.MessageBox.Show("这是一个回调函数");
System.Windows.Forms.MessageBox.Show(result.ToString());
System.Windows.Forms.MessageBox.Show(parameter.AsyncState.ToString()); }
} }

上面是建立的一个类,因时间不多,命名比较随意。

 using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms; namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
} private void button1_Click(object sender, EventArgs e)
{
delegateclass.start();
}
}
}

最新文章

  1. 为什么angularjs使用ui-router时要使用html5Mode?
  2. Packet for query is too large(1767212 &gt; 1048576)mysql在存储图片时提示图片过大
  3. 【模式匹配】Aho-Corasick自动机
  4. Output data in a cursor
  5. android deep link(深度链接)与自定义协议!
  6. jQuery EasyUI教程之datagrid应用(一)
  7. C++ 的全局构造与析构函数
  8. linux下rm误删除数据库文件的恢复方法
  9. keil 51警告编译优化
  10. oracle分组查询
  11. JQ点击高亮显示
  12. 【剑指offer】删除字符也出现在一个字符串
  13. WiFi文件上传框架SGWiFiUpload
  14. centos7,zabbix3.2通过zabbix_java_gateway监控jmx[java/tomcat]
  15. 背水一战 Windows 10 (113) - 锁屏: 将 Application 的 Badge 通知和 Tile 通知发送到锁屏, 将 secondary tile 的 Badge 通知和 Tile 通知发送到锁屏
  16. 【转】最近很火的 Safe Area 到底是什么
  17. Thinkphp5.1 模板路径报错
  18. 了解各种不同意义上的new
  19. HMTL列表详解
  20. 3D建模软件的选择(UG,Solidworks,ProE)

热门文章

  1. BadImageFormatException,未能加载正确的程序集XXX的解决办法
  2. centos7安装etcd
  3. python 使用sqlite3
  4. 【256】◀▶IEW-答案
  5. 将gridview 的数据导出EXCEL
  6. 发起http(s)请求
  7. sklearn保存模型
  8. Linux kernel分析前的准备
  9. kinect2跑高博的orbslam2的过程(仅供自己参考记录)
  10. 微信小程序小结(3) -- 使用wxParse解析html及多数据循环