Question

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();
    }
}
Was it helpful?

Solution

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

OTHER TIPS

Tested with TADOQuery for "select" request.

1) Change "ExecuteOptions" "eoAsyncExecute" and "asAsyncFetch" to True

2) Use event "OnFetchProgress" for determinate, does async request was completed. If "Progress" = "MaxProgress" then async request completed.

Tested with Delphi 2007 and 2009.

You may try a well-respected AsyncCalls unit. It is not more developed after Delphi 2009 was released, but you don't use it anyway.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top