Beispiel #1
0
        /// <summary>
        /// The main loop. Arguments are used to setup Inter-Process Communication, so follow the instructions!
        /// </summary>
        /// <param name="arg0">The first command line argument to the program.</param>
        /// <param name="arg1">The second command line argument to the program</param>
        public static void Loop(String arg0, String arg1)
        {
            pipeIn = new AnonymousPipeClientStream(PipeDirection.In, arg0);
            pipeOut = new AnonymousPipeClientStream(PipeDirection.Out, arg1);
            messageReceiver = new MessageReceiver(pipeIn);
            messageSender = new MessageSender(pipeOut);

            while (thinking)
            {
                Message m = messageReceiver.WaitForMessage();
                if (m is InitMessage)
                    RunInitMessage((InitMessage)m);
                else if (m is ExitMessage)
                    RunExitMessage((ExitMessage)m);
                else if (m is MethodCallMessage)
                    RunMethodCallMessage((MethodCallMessage)m);
                else
                    throw new Exception("Shouldn't have received that kind of message!");
            }
        }