Suppose that your task has to input data from some hardware connected to an RS232 line. You can use the VAX/VMS SYS$QIO system service with your own AST handler to start the input operation, optionally call TASK_PUT_DELAY to set a timeout on the operation, and return to the task fixed-part after having put a request ACT__ASTINT.
When the input completes, VMS hands control to your AST handler which can carry out whatever actions are necessary and then use TASK_ASTMSG(NAME,LENGTH,VALUE,STATUS) to tell the fixed part to call the application again. In this call:
Provided NAME coincides with one of your actions which has requested to be called again, any associated timer is cancelled and your application is called.
TASK_GET_REASON(REASON,STATUS) returns, in REASON, value MESSYS__ASTINT if the message was received from the AST handler, or MESSYS__RESCHED if the timer completed. In the former case, you could use TASK_GET_VALUE(VALUE,STATUS) to get the information passed from the AST handler.
Let us consider an example task called DO_IO with an action called READ.