InfoConnect for Unisys
Control Multiple InfoConnect Workspaces

You can create multiple instances of the InfoConnect. This sample shows how to set up two InfoConnect workspaces so that controls in each workspace can be accessed.

To set up two workspaces

  1. In Visual Studio, create a new Console Application project and add references for the following InfoConnect assemblies. (Depending on your version of Visual Studio, these can be found either on the .NET tab or under Assemblies | Extensions.)
    Attachmate.Reflection
    Attachmate.Reflection.Framework
    Attachmate.Reflection.Emulation.OpenSystems
    Attachmate.Reflection.Emulation.IbmHosts
  2. Replace all the code in the Program.cs file with the following code. This code creates two instances of InfoConnect and opens a session for each. Then it gets text from each session and writes it to the Console.
    Control two workspaces
    Copy Code
    using System;
    using System.Collections.Generic;
    using System.Text;
    using Attachmate.Reflection;
    using Attachmate.Reflection.Emulation.IbmHosts;
    using Attachmate.Reflection.Framework;
    using Attachmate.Reflection.UserInterface;
    using Attachmate.Reflection.Emulation.OpenSystems;
    namespace MultipleWorkSpaces
    {
        class Program
        {
            static void Main(string[] args)
            {
                //Start a visible instance of InfoConnect or get the instance running at the given channel name ("Workspace1")
                Application app1 = MyReflection.CreateApplication("WorkSpace1", true);
    
                //Create a new IBM Session
                IIbmTerminal terminal1 = (IIbmTerminal)app1.CreateControl(new Guid("{09E5A1B4-0BA6-4546-A27D-FE4762B7ACE1}"));
                terminal1.HostAddress = "demo:ibm3270.sim";
    
                //Create a View, making InfoConnect visible to users and then get a handle to the screen
                IFrame frame1 = (IFrame)app1.GetObject("Frame");
                frame1.CreateView(terminal1);
                IIbmScreen screen1 = terminal1.Screen;
    
                //Start a second instance of InfoConnect or get the instance running at the given channel name ("Workspace2")           
                Application app2 = MyReflection.CreateApplication("WorkSpace2", true);
    
                //Open a session in the second workspace
                string sessionPath = Environment.GetEnvironmentVariable("USERPROFILE") + @"\Documents\Micro Focus\InfoConnect\demoSession.rdox";
                ITerminal terminal2 = (ITerminal)app2.CreateControl(sessionPath);
    
                //Create a View for the session in the second workspace, making InfoConnect visible to users, and then get a handle to the screen
                IFrame frame2 = (IFrame)app2.GetObject("Frame");
                frame2.CreateView(terminal2);
                IScreen screen2 = (IScreen)terminal2.Screen;
    
                //Get some text from each of the terminal screens in the two workspaces
                Console.WriteLine("IBM terminal text is" + screen1.GetText(1, 1, 20) + "and UNIX text is" + screen2.GetText(1, 1, screen2.DisplayRows, screen2.DisplayColumns));
            }
        }
    }
                           
    

To test this project

  1. Open InfoConnect and create a new VT session.
  2. In the IP/Address box, enter "demo:UNIX" and then save the session as demoSession.rdox.
  3. In Visual Studio, press F5 to run the session.
  4. Verify that the text from each screen is written to the Console.