gOPCClassicConnector.gAsyncReadItems Method

Top  Previous  Next

Description

Used to read values of OPC Items asynchronously.

This method does not freeze your application like a synchronous method.

And because this is an asynchronous method, results comes with an event: gAsyncReadItemsCompleted

 

VB syntax

gOPCClassicConnector.gAsyncReadItems(itemsToRead() As String, transactionID As String)

 

C# syntax

gOPCClassicConnector.gAsyncReadItems(string[] itemsToRead, string transactionID)

 

Parameters

itemsToRead

Array of ItemIDs of OPC Items that you want to read values of them.

 

transactionID

Transaction id is ID of asynchronous operation, a unique string.

Used in gAsyncReadItemsCompleted  event or to cancel asynchronous operation.

 

Return Type

gOPCClassicFunctionResult

 

C# code example

  try

            {

                //Step1: Create an array of itemIDs and assign ItemIDs

                string[] itemIDs = new string[2]; // = new GelecekCommon.gOPCClassicReadWriteObject();

 

                itemIDs[0] = txtItemID1.Text;

                itemIDs[1] = txtItemID2.Text;

 

                //Step2: Run gAsyncReadItems method  

                GelecekCommon.gOPCClassicFunctionResult function_result = gOPCClassicConnector1.gAsyncReadItems(itemIDs, txtTransactionID.Text);

 

                //Step3: Check function result. For a successfull read, function result should be "OK"

                txtFunctionResult.Text = function_result.ToString();

 

            }

            catch (Exception ex)

            {

                MessageBox.Show(ex.Message);

            }