Exemple #1
0
        static void Main(string[] args)
        {
            myState = ClientState.Init;

            string paramStr = args.Count() >= 2 ? args[1] : "";

            myClient = new ProcessWrapper();
            myClient.Init(null, IOModelHelper.GetIOType(args[0]), paramStr, ProcessControl);
            myClient.UpdateStatus(ProcessWrapper.ProcesssStatus.Running);

            Console.WriteLine("In the client...console");
            myClient.SendProcessMessage("In the client...msg");
            for (int i = 10; i > 0; i--)
            {
                myClient.SendProcessMessage("[CLIENT] Wait for sync..." + i.ToString());
            }
            while (myState != ClientState.Ending && myClient.CheckProgress() != ProcessWrapper.ProcesssStatus.Ending)
            {
                System.Threading.Thread.Sleep(750);
                if (myState == ClientState.Running)
                {
                    myClient.SendProcessMessage("[CLIENT] Wait...");
                }
            }
            myClient.SendProcessMessage("[CLIENT] quitting client process...");
            myClient.SendProcessMessage("QUIT"); // mark to the server that we're done...
            myClient.UpdateStatus(ProcessWrapper.ProcesssStatus.Ending);

            while (myClient.WaitingForWrite())
            {
                myClient.CheckProgress();
            }

            myClient.Cleanup();
        }
Exemple #2
0
        static void Run()
        {
            // this is a simple cycle - reads from host and posts to the process
            StartClient();

            Task <string> readTask = ReadConsoleAsync();

            do
            {
                if (readTask.IsCompleted)
                {
                    string localBuffer = readTask.Result;
                    myHost.SendProcessMessage(localBuffer);  // simplest task possible, echo console data to the worker process
                    readTask = ReadConsoleAsync();
                }
                System.Threading.Thread.Sleep(250);
            } while (myHost.CheckProgress() == ProcessWrapper.ProcesssStatus.Running);

            myHost.Cleanup();
            Console.WriteLine("[SERVER] Client quit. Server terminating.");
        }