Asynchronous Connection

Top  Previous  Next

This method try to establish the connection to the specified Host and Port. This call doesn't block the code execution, so you should use the OnConnect and OnConnectionFail events to determine whether the connection is succesfully established or not. Alternativally, you can make a call to WaitForConnect synchronous method.

 

The Host and Port properties must be set for the connection to be successfully established.

 

 

VB.NET

tnxxxx.Connect()

 

C#

tnxxxx.Connect();

 

 

The following graphic shows the sequence of actions corresponding to the asynchronous Connect method:

 

 Host Integration Pack TN Bridge Vb.net C# Delphi ActiveX asynchronous connection

 

 VB.NET:

 Private Sub cmdConnect_Click(eventSender As object, eventArgs As System.EventArgs)

   tn3270.Host = Edit1.Text

   tn3270.Port = 23

   tn3270.Connect()

 End Sub

 

 Private Sub tn3270_OnConnect(eventSender As object, eventArgs As System.EventArgs)

   MsgBox("Connected")

 End Sub

 

 Private Sub tn3270_OnConnectionFail(eventSender As object, eventArgs As System.EventArgs)

   MsgBox("Connection failed")

 End Sub

 

 C#:

 private void cmdConnect_Click(object eventSender, System.EventArgs eventArgs)

 {

         tn3270.Host = Edit1.Text;

         tn3270.Port = 23;

         tn3270.Connect();

 }

 

 private void tn3270_OnConnect(object eventSender, System.EventArgs eventArgs)

 {

         MsgBox("Connected");

 }

 

 private void tn3270_OnConnectionFail(object eventSender, System.EventArgs eventArgs)

 {

         MsgBox("Connection failed");

 }