


Asynchronous methods
One of the advanced features of ActiveAG is that it makes asynchronous forms of all time-consuming methods available to your program. As used here, asynchronous should be understood to mean non-blocking. That is, an asynchronous method is one that starts and returns control to
your program before it completes the operation it will perform. When the method
finally completes, your program is notified by an
Asynchronous methods are made possible by ActiveAG
When your program uses an Async method, ActiveAG passes that request on to its worker thread. This allows it
to return control to your program immediately. The worker thread then proceeds
to process the command in exactly the same manner as the synchronous form of the method would have been processed. When the
worker thread completes the operation, ActiveAG fires the AsyncCmdDone event to
your program with this information:
In your program
What are asynchronous methods used for? In general, they allow your program to
perform more than one task in a single thread of execution. For example, if
your application has a graphical interface, using asynchronous method calls will
allow the user interface to remain responsive while the program is controlling
the telelphone line.
As another example, you may want to do a database look-up while playing an
Another possible use of asynchronous methods is to write a state machine application that can handle multiple ports (telephone lines) in a single
process. This will require that your application instantiate an array of ActiveAG
instances, but this is easily done in almost any language.
State machine programming is more complex than simple sequential programming
-- but it is an extremely efficient way to implement a multi-port process and it
uses fewer system resources than other methods (port per process or port per thread). At Group W Systems, we have demonstrated a 48 port Visual Basic process
(built with ActiveAG) running in a stress test, so the ability to handle a large
volume of telephony events is not a question.
The
CmdCode as a short integer. This will be one of the Asynchronous completion constants described in the
LineNumber as a short integer. This indicates which line (or ActiveAG
instance) the asynchronous method was invoked for. While this information is redundant
for Visual Basic programmers, it is necessary for using ActiveAG with C++ tools.
Status as a long integer. This value will be one of the status codes described
in the
Finally, a return string as a BSTR. This string is only used when the method
used was the GetTouchTonesAsync method. In this case, it contains any touch-tones that were collected by the
method. For all other methods, this will be an empty (NULL) string.