Example #1
0
        private void ReadUnicodeOutput(object stateInfo)
        {
            byte[] numArray    = new byte[1024];
            string lineOfText1 = string.Empty;
            uint   lpNumberOfBytesRead;

            while (NativeMethodsShared.ReadFile(this.unicodePipeReadHandle, numArray, 1024U, out lpNumberOfBytesRead, NativeMethodsShared.NullIntPtr) && (int)lpNumberOfBytesRead != 0)
            {
                string str = lineOfText1 + Encoding.Unicode.GetString(numArray, 0, (int)lpNumberOfBytesRead);
                while (true)
                {
                    int length;
                    if ((length = str.IndexOf('\n')) != -1)
                    {
                        string lineOfText2 = str.Substring(0, length);
                        str = str.Substring(length + 1);
                        if (lineOfText2.Length > 0 && lineOfText2.EndsWith("\r", StringComparison.Ordinal))
                        {
                            lineOfText2 = lineOfText2.Substring(0, lineOfText2.Length - 1);
                        }
                        this.Log.LogMessageFromText(lineOfText2, this.StandardOutputImportanceToUse);
                    }
                    else
                    {
                        break;
                    }
                }
                lineOfText1 = str;
            }
            if (!string.IsNullOrEmpty(lineOfText1))
            {
                this.Log.LogMessageFromText(lineOfText1, this.StandardOutputImportanceToUse);
            }
            this.unicodeOutputEnded.Set();
        }