zoukankan      html  css  js  c++  java
  • C# 获取Console的输入和输出 数据 (异步)

    using System ;
    using System .Diagnostics;
    using System .IO;
     
    class Program
    {
        static void Main()
        {
            //
            // Setup the process with the ProcessStartInfo class.
            //
            ProcessStartInfo start = new ProcessStartInfo();
            start.FileName = @"D:xxxxxxxxxxxxxxxxxxxxxxxxxx.exe"; // Specify exe name.
            start.UseShellExecute = false;
            start.RedirectStandardOutput = true;
     
            //
            // Start the process.
            //
            using (Process process = Process.Start (start))
            {
                process.OutputDataReceived += new DataReceivedEventHandler(process_OutputDataReceived );
     
                process.BeginOutputReadLine ();
     
                process.WaitForExit ();
            }
        }
     
        static void process_OutputDataReceived( object sender , DataReceivedEventArgs e)
        {
            if (null != e)
            {
                Console.WriteLine (e. Data);
            }
        }
    }
      
  • 相关阅读:
    UVA 12546 LCM Pair Sum
    两两间的距离都是整数的点集
    Codeforces 11.27
    Codeforces 11.27 B
    UVA 105
    打印自身的程序
    Interval DP
    Tree DP
    参加第五次全国工程建设行业信息化建设高峰论坛 (个人的一点感想)
    基础资料分类及清单版本管理
  • 原文地址:https://www.cnblogs.com/muzizongheng/p/3169145.html
Copyright © 2011-2022 走看看