Server Reference Guide : .NET Interface : Classes : Example
 
Share this page          
Example
The following example assumes that the Server Manager has been used to create the AkaName “comtest” pointing to the non-ASOLib comtest.img application.
using System;
 using Ca.OpenROAD;
 
namespace ExampleApp
{
    class Class1
    {
        static void Main(string[] args)
        {
            RemoteServer rso = null;
            //
            // This illustrates both explicit and implicit flavors of Dispose.
            // The RSO Dispose is done explicitly via the try/finally construct,
            // while the PDO Dispose is implicit in the ôusingö statement.
            //
            try
            {
                rso = new RemoteServer();

                string decls = "hellostring=STRING;counter=INTEGER";

                using (ParameterData pdo = new ParameterData(decls))
                {
                    rso.Connect("comtest", null, null);
                    pdo.SetAttr("hellostring", "Hello .NET");

                    rso.CallProc("helloworld", null, pdo);
                    Console.WriteLine("hellostring = {0}",pdo.GetAttr("hellostring"));
                    Console.WriteLine("counter     = {0}",pdo.GetAttr("counter"));
                }
            }
            finally
            {
                if (rso != null)
                    rso.Dispose();
            }
        }
    }
}