C#异步编程
//窗口类中:普通类成员函数 private int recv1(int num) { //string strInfo = Convert.ToString(num); //label1.Text = strInfo; System.Threading.Thread.Sleep(1000); return num; } private void button1_Click(object sender, EventArgs e) { Calcul cal = recv1;//定义委托对象 IAsyncResult re = cal.BeginInvoke(20, null, null);//执行 int rt1 = cal.EndInvoke(re);//阻塞等待结果 label1.Text = rt1.ToString(); } //声明委托 public delegate int Calcul(int num);
当前名称:C#异步编程
网站地址:http://ybzwz.com/article/pgcsjh.html