Difference between revisions of "Midware TMWTable.Send"

From Overbyte
Jump to navigation Jump to search
 
Line 6: Line 6:
  
 
== Description ==
 
== Description ==
 +
Send a FunctionCode  and Request (parmeters) to the application server. This is the main TAppSrvClient component function. Communication with MidWare application server is established if needed. Connection can be later closed using Close method.
 +
 +
Send is asynchronous. Execution is almost instantaneous: control return back immediately while sending occurs in the background. Eventually, when request is done, either OK or with some error, then the OnRequestDone event is triggered.
 +
 +
Asynchonous operation allows multitasking without using threads. That's important because most VCL is not thread safe. Asynchonous operation let you do some work while your request are processed. You may even start several requests at once. But asynchronous operation may be somewhat new to traditionnal programmers which like sequential programming. Asynchronous programming can be made easy using some kind of "finite state machine" to keep track of the processing state and know what to do next when an operation has been completed. This give very powerful applications.
 +
 +
For those who really wants blocking operation, asynchronous operation may be transformed in blocking operation by means of a loop and a flag. Before sending a request, you set a flag to false, then you loop calling Application.ProcessMessages until the flag is set to true or some timeout occured. You set then flag to true in the OnRequestDone event handler.

Latest revision as of 12:34, 24 May 2011

Main page -> Midware component reference -> TMWTable -> Send

Definition

procedure Send;

Description

Send a FunctionCode and Request (parmeters) to the application server. This is the main TAppSrvClient component function. Communication with MidWare application server is established if needed. Connection can be later closed using Close method.

Send is asynchronous. Execution is almost instantaneous: control return back immediately while sending occurs in the background. Eventually, when request is done, either OK or with some error, then the OnRequestDone event is triggered.

Asynchonous operation allows multitasking without using threads. That's important because most VCL is not thread safe. Asynchonous operation let you do some work while your request are processed. You may even start several requests at once. But asynchronous operation may be somewhat new to traditionnal programmers which like sequential programming. Asynchronous programming can be made easy using some kind of "finite state machine" to keep track of the processing state and know what to do next when an operation has been completed. This give very powerful applications.

For those who really wants blocking operation, asynchronous operation may be transformed in blocking operation by means of a loop and a flag. Before sending a request, you set a flag to false, then you loop calling Application.ProcessMessages until the flag is set to true or some timeout occured. You set then flag to true in the OnRequestDone event handler.