using System;
using System.Collections.Generic;
using System.Text;
namespace QuickFramework2006
{
public class AsyncDemo
{
public AsyncDemo()
{
}
public int TestMethod(int count)
{
int result = 0;
for (int i = 0; i < count; i++)
{
result += i;
System.Threading.Thread.Sleep(100);
}
return result;
}
//public delegate int xxxx(int count);
//private void button4_Click(object sender, EventArgs e)
//{
// AsyncDemo demo = new AsyncDemo();
// xxxx caller = new xxxx(demo.TestMethod);
// IAsyncResult result = caller.BeginInvoke(40, new AsyncCallback(Callback), caller);
//}
//private void Callback(IAsyncResult async)
//{
// xxxx caller = (xxxx)async.AsyncState;
// int sum = caller.EndInvoke(async);
// MessageBox.Show("运行完成,结果为:" + sum.ToString());
//}
}
}