Ejemplo n.º 1
0
        /// <summary>
        /// 对收到的帧进行分类。
        /// </summary>
        protected async void HandleAnswers()
        {
            try
            {
                while (true)
                {
                    FrameBase frame = await base.Answers.WaitAsync(-1);

                    switch (frame)
                    {
                    case RedirectedOutputFrame redirectedOutputFrame:
                    {
                        RedirectedOutputFrames.Release(redirectedOutputFrame);
                    }
                    break;

                    case RedirectedErrorFrame redirectedErrorFrame:
                    {
                        RedirectedErrorFrames.Release(redirectedErrorFrame);
                    }
                    break;

                    default:
                    {
                        OtherFrames.Release(frame);
                    }
                    break;
                    }
                }
            }
            catch
            {
            }
        }
Ejemplo n.º 2
0
        public override void Dispose()
        {
            base.Dispose();
            if (!Disposed)
            {
                Disposed = true;

                RedirectedOutputFrames.Dispose();
                RedirectedErrorFrames.Dispose();
                OtherFrames.Dispose();
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 读取程序输出。
        /// </summary>
        /// <exception cref="Exception"></exception>
        /// <returns></returns>
        public async Task <string> ReadStandardOutputAsync()
        {
            if (Started)
            {
                RedirectedOutputFrame frame = await RedirectedOutputFrames.WaitAsync(-1).ConfigureAwait(false);

                if (frame.Exited)
                {
                    Exited = true;
                }
                return(frame.Data);
            }
            else
            {
                throw new InvalidOperationException();
            }
        }