EPI call synchronization types

The EPI COM classes support synchronous ("blocking") and deferred synchronous ("polling") protocols. The Visual Basic environment does not support the asynchronous calls that are available in the C++ classes.

In the previous example a Session object was used with the default synchronization type of cclSync. When this Session object was used as the first parameter on Terminal.Start or Terminal.Send, a synchronous link call was made to CICS®. The Visual Basic program was then blocked until the reply was received from CICS. When the call returned updated screen data from CICS was immediately available in the Screen object.

To make a deferred synchronous call you use the Session.SetSyncType method to set the Session to cclDSync. When this Session object is used on a Terminal.Start or Terminal.Send call, the screen contents are transmitted to CICS as 3270 data stream, but the method returns immediately. This allows the Visual Basic program to continue other tasks, including user interactions, while the CICS server transaction is running. Further 3270 screen updates from CICS must be retrieved later using the Poll method on the Terminal object:
        Sub EPIDSync_Click()
            'Create a session object (deferred synchronous)
            Set Session = New CclOSession
            Session.SetSyncType cclDSync
            Terminal.Start Session, "CESN", ""
        End Sub
The transaction is now in progress in the CICS server. At a later stage (in response to a user action, or when the Visual Basic program has completed some other task) the Terminal.PollForReply method is used to collect the reply from CICS:
Sub EPIReply_Click()
  If terminal.State <> cclDiscon And terminal.State <> cclError Then
    If terminal.PollForReply Then
      'Screen has been updated, output some fields
      Set Screen = Terminal.Screen
      Set Field = Screen.FieldByIndex(1)
      List1.AddItem Field.Text
    Else
      List1.AddItem "No Reply from CICS yet"
    End If
  End If
End Sub

A CICS server transaction may send more than one reply in response to a Terminal.Start or Terminal.Send call. More than one Terminal.PollForReply call may therefore be needed to collect all the replies. Use the Terminal.State method to find out if further replies are expected. If there are, the value returned will be cclServer.