The ConnectAsync method is used to establish a connection to the runtime system through an asynchronous call that does not block the client application calling it. When the connection is established, a specified callback handler is triggered to process the connection result.
Namespace – ABSuite.AccessLayer.Connector.Core
Assembly – Unisys.ABSuite.AccessLayer.Connector.Core (in Unisys.ABSuite.AccessLayer.Connector.Core.dll)
Syntax
Task<TransmissionObject> ConnectAsync( ConnectionDetails details, ATTConnectionDetails attDetails )
Arguments
details – This argument provides the connection details in an instance of the ConnectionDetails class.
The ConnectionDetails class defines properties required to establish a connection with the runtime system through the Access Layer API. To use the ConnectionDetails class with the ConnectAsync method, an instance of the class must be created and populated with the required information to be used by the ConnectAsync method.
Refer to the description of the Connect method for more information on the ConnectionDetails class members.
attDetail – This argument provides the ATT recording configuration details in an instance of the ATTConnectionDetails class.
The ATTConnectionDetails class provides properties that are required to record and playback test cases by using ATT.
Refer to the description of the Connect method for more information on the ATTConnectionDetails class members.
Return Value
This method executes an awaitable task and returns a TransmissionObject instance that specifies the current context of the system.
Using the IConnection Interface for the ConnectAsync Method
The following code shows an example of using the ConnectAsync() method to perform an asynchronous connection to the host system:
// Async Method to establish a host connection. public async void EstablishHostSessionAsync() { // Create a new connection to the AB Suite host system // Use the Access Layer API ConnectionFactory to create // an instance of a Connection class ABSConnection = ConnectionFactory.Create(); // Set up the ConnectionDetails object with the required entries ConnectionDetails cDetails = new ConnectionDetails() { Host = “localhost”, // Host name or IP Address System = “Sample”, // Name of the Runtime System IsAnonymous = true, // Set anonymous access if required AssemblyLocation = @"C:\ABSuite\Datamodels" // Sets the location of DataModels Assembly }; // Perform the ConnectAsync call using the defined connection details. // No ATT recording is required. Therefore, the second parameter // is set to null. // We can await the ConnectAsync Task that lets the calling // thread to continue processing. It returns an instance of the // TransmissionObject. TransmissionObject trObj = null; trObj = await ABSConnection.ConnectAsync(cDetails, null); ApplicationLogger.LogInfo(() => string.Format("<Test Client>:: After Connect call!!")); if (trObj != null && (trObj.State == TransmissionReturnCode.Ok || trObj.State == TransmissionReturnCode.OkWithSwitch)) { CurrentIspecName = trObj.ObjectClassName; CurrentTO = trObj; } SessionConnected = true; }