首页 > 代码库 > 【摘要】多线程 - BeginInvoke异步调用

【摘要】多线程 - BeginInvoke异步调用

private delegate int MyMethod();private int method(){    Thread.Sleep(10000);    return 100;}private void MethodCompleted(IAsyncResult asyncResult){    if (asyncResult == null) return;    textBox1.Text = (asyncResult.AsyncState as     MyMethod).EndInvoke(asyncResult).ToString();}private void button1_Click(object sender, EventArgs e){    MyMethod my = method;    IAsyncResult asyncResult = my.BeginInvoke(MethodCompleted, my);}

摘录自

【摘要】多线程 - BeginInvoke异步调用