Watch, Follow, &
Connect with Us

For forums, blogs and more please visit our
Developer Tools Community.


Welcome, Guest
Guest Settings
Help

Thread: TFDQuery execute block application GUI.


This question is answered. Helpful answers available: 1. Correct answers available: 1.


Permlink Replies: 5 - Last Post: Sep 11, 2014 9:01 PM Last Post By: Jitendra Gouda
Jitendra Gouda

Posts: 11
Registered: 3/2/13
TFDQuery execute block application GUI.  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Aug 25, 2014 11:55 PM
Hi,

I am getting one issue with TFDQuery that when we open a query component and if it takes time to get very large amount of data then it blocks application GUI. User cannot do any interaction with application till Query execution finished.

In our project we have a scenario where we need to do user interaction while query is executing. It should not block the GUI.
I found that Query component ResourceOptions -> CmdExecMode property controls this behavior. And in some site it is suggested to set it amAsync to un-block GUI. I did it but still I get same issue.

So could anyone please suggest how to fix above issue that FDQuery component will execute and should not block GUI. So that user can perform some other task while query is executing.

One more thing I want to ask that if we set CmdExecMode to amAsync. then is there any problem for queries that take longtime to get data.
for example..

FDQuery1.Resourceoptions.CmdExecMode := amAsync;
FDQuery1.sql.text := Select * from Table1; /// Table 1 have very large amount of data. ///
FDQuery1.Open; /// it takes time to get all data ///
showmessage(FDquery1.fieldbyname('Field1').asstring); /// will exception occur in this statement as FDQuery1 will take time to execute and on that period Showmessage statement executed ///

So please correct me if I am wrong. And please provide your solutions and suggestion.

Thanks,
Jitendra

quinn wildman

Posts: 856
Registered: 12/2/99
Re: TFDQuery execute block application GUI.
Helpful
Click to report abuse...   Click to reply to this thread Reply
  Posted: Aug 26, 2014 11:27 AM   in response to: Jitendra Gouda in response to: Jitendra Gouda
Jitendra Gouda wrote:
So could anyone please suggest how to fix above issue that FDQuery component will execute and should not block GUI.

You need to run the Query in a different thread.
Jitendra Gouda

Posts: 11
Registered: 3/2/13
Re: TFDQuery execute block application GUI.  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Sep 11, 2014 9:00 PM   in response to: quinn wildman in response to: quinn wildman
quinn wildman wrote:
Jitendra Gouda wrote:
So could anyone please suggest how to fix above issue that FDQuery component will execute and should not block GUI.

You need to run the Query in a different thread.


I executed query in different thread. And also marked TAdquery.ResourceOptions.Silentmode:=True. It solved my issue.

Thanks all for your help../

--
MR JKG

Guest
Re: TFDQuery execute block application GUI.
Click to report abuse...   Click to reply to this thread Reply
  Posted: Aug 30, 2014 7:34 AM   in response to: Jitendra Gouda in response to: Jitendra Gouda
Jitendra Gouda wrote:
Hi,

In our project we have a scenario where we need to do user interaction while query is executing. It should not block the GUI.
I found that Query component ResourceOptions -> CmdExecMode property controls this behavior. And in some site it is suggested to set it amAsync to un-block GUI. I did it but still I get same issue.

I'm facing a similar problem, but unfortunately amAsync won't do it for me. In this mode you might need to handle the AfterOpen event as in the sample project Async.dpr, which can be foud at <FireDACFolder>\Samples\Comp Layer\TADQuery\ExecSQL.

Best,
Carlos
Mike Margerum

Posts: 590
Registered: 12/1/99
Re: TFDQuery execute block application GUI.  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Aug 31, 2014 3:59 PM   in response to: Jitendra Gouda in response to: Jitendra Gouda
You could try using TAnonymousThread
Jitendra Gouda

Posts: 11
Registered: 3/2/13
Re: TFDQuery execute block application GUI.  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Sep 11, 2014 9:01 PM   in response to: Jitendra Gouda in response to: Jitendra Gouda
I executed query in different thread. And also marked TAdquery.ResourceOptions.Silentmode:=True. It solved my issue.

Thanks all for your help.
Legend
Helpful Answer (5 pts)
Correct Answer (10 pts)

Server Response from: ETNAJIVE02