Proxy Service Interface C# Sample for Stateless and Stateful Tasks

These samples execute a task or series of tasks and display the results. The task is defined in a sample task file generated in the designer.

Stateless Proxy Service Interface C# Sample

using System;
using System.Xml;
using SCREENCONNECTORLib;

namespace CSharpApp
{
  class Test
  {
    [STAThread]
    static void Main(string[] args)
    {
           try
      {
        //Instantiate and initialize the proxy
        IConnectorProxy proxy = new ScreenConnectorProxyClass();
       
        //Execute a stateless task
        String result = proxy.Execute("com.attachmate.connectors.screen.ScreenConnectorAccessImpl", 
"C:\\Program Files\\Attachmate\\EAI\\recordings\\Test\\connector\\Test.xml", "Task", 
"<ScreenInputs><Input>data</Input></ScreenInputs>");

        //Display the results
        System.Console.Out.WriteLine(result);
      }
      catch (Exception xx)
      {
        System.Console.Error.WriteLine(xx.ToString());
      }
    }
  }
}

Stateful Proxy Service Interface C# Sample

using System;
using System.Xml;
using SCREENCONNECTORLib;

namespace CSharpApp
{
  class Test
  {
    [STAThread]
    static void Main(string[] args)
    {
	 IConnectorProxy proxy = null;
	 try
         {
        	//Instantiate the proxy
        	proxy = new ScreenConnectorProxyClass();

		//Initialize the proxy for stateful execution
proxy.Open("com.attachmate.connectors.screen.ScreenConnectorAccessImpl", 
"C:\\Program Files\\Attachmate\\EAI\\recordings\\Test\\connector\\Test2.xml");

		//Execute a stateful task
         	String result1 = proxy.Exec("StatefulTask1",
"<ScreenInputs><Input>data1</Input></ScreenInputs>");
	       System.Console.WriteLine(result1);

		//Execute a second stateful task
         	String result2 = proxy.Exec("StatefulTask2",
"<ScreenInputs><Input>data2</Input></ScreenInputs>");
	       System.Console.WriteLine(result2);
		}
		catch (Exception xx)
		{			
                      System.Console.Error.WriteLine(xx);
		}
		finally
		{
		//Clean up
	        proxy.Close();
         }
      }
   }
}
Related Topics
Bullet Using Tasks in Your Applications, Overview
Bullet Sample Task File
Bullet Building Applications Using Native Win32 Technologies
Bullet Proxy Service Interface API Reference
  Attachmate