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);
        }

posted on 2008-05-05 19:52  TeeBye  阅读(366)  评论(0编辑  收藏  举报

导航