AnyDAC
ContentsIndexHome
PreviousUpNext
TADResourceOptions.CmdExecMode Property

Controls DBMS action execution mode.

Group
Links

Use CmdExecMode property to control DBMS action execution mode, at first it synchronism:

Mode 
Description 
amBlocking 
The calling thread and GUI are blocked until an action will be finished. 
amNonBlocking 
The calling thread is blocked until an action will be finished. The GUI is not blocked. 
amCancelDialog 
The calling thread and GUI are blocked until an action will be finished. AnyDAC shows dialog, allowing to cancel an action. 
amAsync 
The calling thread and GUI are not blocked. The called method will return immediately. 

The default value is amBlocking. This property controls the following methods synchronism:

  • TADDataSet.Open, TADCustomCommand.Open, IADPhysCommand.Open;
  • TADDataSet.Execute, TADCustomCommand.Execute, IADPhysCommand.Execute;
  • fetching in TADDataSet, TADCustomCommand.Fetch, IADPhysCommand.Fetch.

If mode is amNonBlocking, then application continues to process GUI messages, but ignores mouse and keyboard events. 

If mode is amCancelDialog, then application should include TADGUIxAsyncExecuteDialog component into any form or data module. If it is not included, then exception will be raised. 

The dialog has the "Cancel" button, allowing to terminate current action. If DBMS does not support action canceling, then button will be hidden. 

If mode is amAsync, an application can get notification about action finish using appropriate event handler or callback:

Class 
Method 
Event 
TADDataSet 
Open 
AfterOpen event 
 
Execute 
AfterExecute event 
TADCustomCommand 
Open 
AfterOpen event 
 
Execute 
AfterExecute event 
 
Fetch 
AfterFetch event 
IADPhysCommand 
Open 
StateHandler.HandleFinished callback 
 
Execute 
StateHandler.HandleFinished callback 
 
Fetch 
StateHandler.HandleFinished callback 

Application can control action timeout by setting CmdExecTimeout property.

property CmdExecMode: TADStanAsyncMode;

Asynchronous Execution, CmdExecTimeout, TADDataSet.Open, TADCustomCommand.Open, IADPhysCommand.Open, TADDataSet.Execute, TADCustomCommand.Execute, IADPhysCommand.Execute, TADCustomCommand.Fetch, IADPhysCommand.Fetch

See demos:

  • AnyDAC\Samples\Comp Layer\TADQuery\ExecSQL\Async;
  • AnyDAC\Samples\Phys Layer\IADPhysCommand\Async.
What do you think about this topic? Send feedback!