Ejemplo n.º 1
0
        public static string Read(int exp_cnt)
        {
            char[] buffer = new char[100];

            int cnt = 0;

            try
            {
                while (true)
                {
                    char c = (char)cp.ReadChar();
                    buffer[cnt] = c;
                    cnt++;
                    if (cnt > 1 &&
                        ((c == 'k' && buffer[cnt - 2] == 'O') ||
                         (c == 'r' && buffer[cnt - 2] == 'E') ||
                         cnt == exp_cnt))
                    {
                        break;
                    }
                }
            }
            catch (TimeoutException)
            {
            }
            catch (ArgumentException)
            {
            }

            if (cnt > 0)
            {
                return(new String(buffer, 0, cnt));
            }

            return(null);
        }