Invoke异步操作类
Invoke异步操作类
调用方法 private void button1_Click(object sender, EventArgs e)
{
ThreadPool.QueueUserWorkItem(new WaitCallback(work),"byf");
}
public void work(object param)
{
BackgroundCommand command = new BackgroundCommand();
command.CompleteCallback += new AsyncCallback(command_CompleteCallback);
command.DoExecute += new BackgroundCommand.CommandExecuteHandler(command_DoExecute);
command.CompleteExecute += new SendOrPostCallback(command_CompleteExecute);
IAsyncResult aresult = command.BeginExecute(param);
command.EndExecute(aresult);
}