Async ZQuery.Open lazarus / 16-Databases ---------------------------------------------------------------------- DarkCall · 2021-10-28 18:48 My application is totally interrupted when I do ZQuery.Open; Is there a way to make it an Asynchronous command? ---------------------------------------------------------------------- loaded · 2021-10-29 06:30 You can try using thread. ---------------------------------------------------------------------- DarkCall · 2021-10-29 18:40 How to start? Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i procedure TForm2.DBComboLookupClick(Sender: TObject);begin   FCounter := FCounter+1;   Application.QueueAsyncCall(@Async,FCounter);end; procedure TForm2.Async(Data: PtrInt);begin  ZConnection1.ZQuery1.Open;end; It's still pause my application until ZQuery opened. [Edited to add code tags; please read How to use the Forum.] ---------------------------------------------------------------------- loaded · 2021-10-30 03:44 Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i unit Unit1; {$mode objfpc}{$H+} interface uses  Classes, SysUtils, DB, Forms, Controls, Graphics, Dialogs, ExtCtrls, StdCtrls,  DBGrids, ZConnection, ZDataset;type  { TH_for_zqoon }  TH_for_zqoon = class(TThread)  private    procedure Opened;  protected    procedure Execute; override;  end;   { TForm1 }  TForm1 = class(TForm)    Button_database_opener: TButton;    ZConnection1: TZConnection;    ZQuery1: TZQuery;    procedure Button_database_openerClick(Sender: TObject);  private   public   end; var  Form1: TForm1;implementation{$R *.lfm}{ For Thread }procedure TH_for_zqoon.Opened;begin Showmessage('Zquery Opened');end; procedure TH_for_zqoon.Execute;begin Form1.ZQuery1.Open; Synchronize(@Opened);en d; { TForm1 }procedure TForm1.Button_database_openerClick(Sender: TObject);var  Zopener : TH_for_zqoon;begin  Zopener:=TH_for_zqoon.Create(false);end;end. ---------------------------------------------------------------------- mangakissa · 2021-11-01 15:32 Quote from: DarkCall on October 28, 2021, 08:48:03 pmMy application is totally interrupted when I do ZQuery.Open; Is there a way to make it an Asynchronous command? Is this always when you open queries or only for this particulair? You're not giving much information about the query. I'm not a fan of using queries in threads if you nothing more than just open it.