public static void Main(String[] args) { try { int result = (int)EnumResultCode.S_OK; EndEvent = new AutoResetEvent(false); Console console = new Console(); MyWin32.HandlerRoutine handlerRoutine = new MyWin32.HandlerRoutine(MyWin32.Handler); MyWin32.SetConsoleCtrlHandler( handlerRoutine, true); console.CreateOpcClient(); // gets the OpcClient instance OpcClient client = console.OpcClient; // initialize the client instance if (!ResultCode.SUCCEEDED(client.Initialize())) { client = null; return; } // end if // initialize the AE client simulation result |= m_opcClient.InitializeAeObjects(); Usage(); bool end = false; while (!Console.End && !end) { String read = System.Console.ReadLine(); switch (read) { case "A": client.activateObjectsAsync(); break; case "a": client.activateObjectsSync(); break; case "C": client.connectObjectsAsync(); break; case "c": client.connectObjectsSync(); break; case "D": client.disconnectObjectsAsync(); break; case "d": client.disconnectObjectsSync(); break; case "E": case "e": case "Q": case "q": { end = true; } break; default: { Usage(); } break; case "S": client.getServerStatusAsync(); break; case "s": client.getServerStatusSync(); break; case "M": case "m": client.activateConnectionMonitor(); break; case "N": case "n": client.deactivateConnectionMonitor(); break; } } // end while client.Terminate(); client = null; MyWin32.Handler(MyWin32.CtrlTypes.CTRL_CLOSE_EVENT); } catch (Exception exc) { System.Diagnostics.Debug.WriteLine(exc.Message + exc.Source + exc.StackTrace + exc.TargetSite); } // end try...catch } // end Main