c# 回调委托
2016-06-16 09:50
330 查看
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; namespace Wind2 { public partial class Form1 : Form { public delegate int del(int num1, int num2); public Form1() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { del a = test; int num1 = int.Parse(this.textBox1.Text); int num2 = int.Parse(this.textBox2.Text); a.BeginInvoke(num1, num2,method, a); } public int test(int num1, int num2) { int sum = 0; for (int i = num1; i <= num2; i++) { sum += num1; num1++; } return sum; } public void method(IAsyncResult res) { if (res != null) { this.label1.Text=(res.AsyncState as del).EndInvoke(res).ToString(); } } private void Form1_Load(object sender, EventArgs e) { Control.CheckForIllegalCrossThreadCalls = false; } } }
相关文章推荐
- C#中调用abobe reader打开PDF文件的方法
- C#用递归算法实现:一列数的规则如下: 1、1、2、3、5、8、13、21、34,求第30位数是多少
- C# ?、?? 问号和2个问号的用法(类型?、对象?)
- C#游戏框架uFrame
- C#递归算法之快速排序
- 唤起你对c#曾经的记忆
- Excel在C#中的导入导出,并对值进行简单修改
- C# 发送邮件中包含图片
- c#书
- 【笔记】C#实现快捷键(系统热键)响应的方法
- VS2015中C#版本6.0的新特性 你需要知道
- C# 动态获取、修改、更新配置文件 实现思路
- QQlite 插件开发总结
- c#3.0新特性
- 常用的日期格式
- 设计模式之迭代器模式
- C# WinForm键盘按键响应 实现思路
- WinForm中DataGridView导出为Excel(快速版)
- C#中的委托
- C#设计模式—桥接模式