示例#1
0
        public void Run()
        {
            Thread m_signalThread = new Thread(SignalThread);

            m_signalThread.Start();

            Pollfd[] fds = new Pollfd[2];

            while (m_exit == false)
            {
                fds[0].fd      = Mono.Unix.UnixStream.StandardInputFileDescriptor;
                fds[0].events  = PollEvents.POLLIN;
                fds[0].revents = 0;

                fds[1].fd      = m_netPipe.Reading.Handle;
                fds[1].events  = PollEvents.POLLIN;
                fds[1].revents = 0;

                int ret = Syscall.poll(fds, -1);

                if (ret == 0)
                {
                    //ChiConsole.Prompt = String.Format("pr{0}> ", z++);
                    ChiConsole.WriteLine("timeout");
                }
                else if (ret > 0)
                {
                    if (fds[0].revents != 0)
                    {
                        m_textConsole.ReadChars();

                        string str;
                        while ((str = m_textConsole.GetLine()) != null)
                        {
                            //m_textConsole.WriteLine("Tuli {0}", str);
                            HandleInput(str);
                        }
                    }

                    if (fds[1].revents != 0)
                    {
                        m_netPipe.Reading.ReadByte();
                        m_synchronizedInvoke.DispatchInvokes();
                    }
                }
            }

            Dbg.WriteLine("Exiting");

            m_sigThreadStop = true;
            if (m_signalThread.Join(1000) == false)
            {
                m_signalThread.Abort();
            }

            m_textConsole.UnInit();
        }