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); }
时间: 2024-10-08 01:30:08