后台工作德尔福 [英] Background Worker Delphi

查看:279
本文介绍了后台工作德尔福的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想美元的过程p $ ppare异步进程中的 Delphi的Borland公司2006年你知道怎么样?

  application.ProcessMessages;
  dm001.Proc.Close;
  dm001.Proc.Parameters.Clear;
  dm001.Proc.ProcedureName:='[DBO] [实施例]';
  dm001.Proc.Parameters.AddParameter.Name:='@idEXAMPLE';
  dm001.Proc.Parameters.ParamByName('@ ID)数据类型:=榜样;
  。dm001.Proc.Parameters.ParamByName('@ ID)值:=榜样;
  dm001.Proc.Open;

例在C#

私人无效bw_DoWork(对象发件人,DoWorkEventArgs E)
{
    BackgroundWorker的工人=发件人为BackgroundWorker的;    的for(int i = 1;(I< = 10);我++)
    {
        如果((worker.CancellationPending == true)而)
        {
            e.Cancel =真;
            打破;
        }
        其他
        {
            //执行耗时的操作,并报告进展情况。
            System.Threading.Thread.Sleep(500);
            worker.ReportProgress((我* 10));
        }
    }
}

私人无效buttonStart_Click(对象发件人,RoutedEventArgs E)
{
    如果(bw.IsBusy!= TRUE)
    {
        bw.RunWorkerAsync();
    }
}


解决方案

BackgroundWorker的是不是一个线程执行不了多少。但也有仿效德尔福这种行为,如 TBackgroundWorker <一个组件/ p>

I would like to prepare asynchronous process for procedure in Delphi Borland 2006 do you know how?

application.ProcessMessages;
  dm001.Proc.Close;
  dm001.Proc.Parameters.Clear;
  dm001.Proc.ProcedureName:='[dbo].[EXAMPLE]';
  dm001.Proc.Parameters.AddParameter.Name:='@idEXAMPLE';
  dm001.Proc.Parameters.ParamByName('@id').DataType:="example";
  dm001.Proc.Parameters.ParamByName('@id').Value:="example";
  dm001.Proc.Open;

Example in C#

private void bw_DoWork(object sender, DoWorkEventArgs e)
{
    BackgroundWorker worker = sender as BackgroundWorker;

    for (int i = 1; (i <= 10); i++)
    {
        if ((worker.CancellationPending == true))
        {
            e.Cancel = true;
            break;
        }
        else
        {
            // Perform a time consuming operation and report progress.
            System.Threading.Thread.Sleep(500);
            worker.ReportProgress((i * 10));
        }
    }
}

or

private void buttonStart_Click(object sender, RoutedEventArgs e)
{
    if (bw.IsBusy != true)
    {
        bw.RunWorkerAsync();
    }
}

解决方案

BackgroundWorker is not much more than a thread implementation. But there are a Components that emulate this behaviour on Delphi, such as TBackgroundWorker

这篇关于后台工作德尔福的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆