Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/delphi/8.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在Delphi中使用LocalAsyncVclCall_Delphi - Fatal编程技术网

在Delphi中使用LocalAsyncVclCall

在Delphi中使用LocalAsyncVclCall,delphi,Delphi,实际上,我正在使用库以这种方式异步执行查询 while AsyncMultiSync([RunQuery], True, 10) = WAIT_TIMEOUT do begin FrmProgress.refresh; //Update the ellapsed time in a popup form Application.ProcessMessages; end; 一切正常 现在,我想对在网格中加

实际上,我正在使用库以这种方式异步执行查询

       while AsyncMultiSync([RunQuery], True, 10) = WAIT_TIMEOUT do
       begin
            FrmProgress.refresh; //Update the ellapsed time in a popup form
            Application.ProcessMessages; 
       end;
一切正常

现在,我想对在网格中加载查询执行相同的操作

所以我试过这个

         while LocalAsyncVclCall(@InitGrid, 10) = WAIT_TIMEOUT do
         begin
              FrmProgress.refresh;
              Application.ProcessMessages;
         end;
但是显然没有编译,因为LocalAsyncVclCall返回的类型是
IAsyncCall
,而不是基数

我也试过了,但不起作用,因为initgrid过程是异步执行的

             while not LocalAsyncVclCall(@InitGrid, 10).Finished do
             begin
                  FrmProgress.refresh;
                  //Application.ProcessMessages;
             end;
procedure InitGrid;   
begin
  cxGrid1DBTableView1.BeginUpdate;
  try    

       cxGrid1DBTableView1.DataController.DataSource:=DataSource1;//in this point assign the query previously executed to the grid. 

       cxGrid1DBTableView1.ClearItems;
       cxGrid1DBTableView1.DataController.CreateAllItems;

       for ColIndex:=0 to cxGrid1DBTableView1.ColumnCount-1 do
       cxGrid1DBTableView1.Columns[ColIndex].Options.Editing:=False;

  finally
    cxGrid1DBTableView1.EndUpdate;
  end;

end;
如何使用LocalAsyncVclCall或其他函数异步执行VCL代码

我想要这样的东西

             while ExecuteMyVCLProcedure(@InitGrid) = WAIT_TIMEOUT do
             begin
                  FrmProgress.refresh;
                  //Application.ProcessMessages;
             end;
更新 InitGrid过程在这里进行,TcxGrid不提供任何事件来显示数据加载的进度。因为我想异步执行这个过程

             while not LocalAsyncVclCall(@InitGrid, 10).Finished do
             begin
                  FrmProgress.refresh;
                  //Application.ProcessMessages;
             end;
procedure InitGrid;   
begin
  cxGrid1DBTableView1.BeginUpdate;
  try    

       cxGrid1DBTableView1.DataController.DataSource:=DataSource1;//in this point assign the query previously executed to the grid. 

       cxGrid1DBTableView1.ClearItems;
       cxGrid1DBTableView1.DataController.CreateAllItems;

       for ColIndex:=0 to cxGrid1DBTableView1.ColumnCount-1 do
       cxGrid1DBTableView1.Columns[ColIndex].Options.Editing:=False;

  finally
    cxGrid1DBTableView1.EndUpdate;
  end;

end;

提前感谢。

使用PostMessage向FrmProgress发送自定义windows消息

e、 g

更新InitGrid过程 在这里,TcxGrid不提供任何 事件以显示数据的进度 负载因为我想执行 此过程是异步执行的

您不能在不同的VCL线程中填充cxGrid,因为只有一个VCL线程,即主线程。从主线程调用LocalAsyncVclCall只不过是在调用LocalAsyncVclCall的线程中执行给定的函数。因此,它与在ProcessMessages()调用所在的同一线程中调用InitGrid()函数没有任何不同。因此,在将数据加载到cxGird后,将调用ProcessMessages(),这不是您想要的。
所有的*VclCall()函数都是从与主线程不同的线程执行的


如果不更改cxGrid的代码以支持“进度事件”,您的尝试就没有希望了。

什么是“我也尝试了,但没有成功。”在
上方,而不是localasyncvclall(@InitGrid,10)。完成了
行的意思是什么?你需要明确,因为“不起作用”不会告诉任何人任何有帮助的事情。此外,您没有执行任何需要LocalAsyncVclCall(或任何其他类型的Async*调用)的操作。您所做的事情可以在InitGrid过程本身内轻松完成,就像您只需刷新表单并调用Application.ProcessMessages(这是一件坏事,但完全是另一个主题)一样。@Ken,我只是更新了这个问题。与LocalAsyncVclCall的问题无关,因此没有答案。