以下的代码为new Process() 调用cmd命令,并将结果异步回显到Form的例子:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Diagnostics;
namespace CmdCallbackShow
{
// 1.定义委托
public delegate void DelReadStdOutput(string result);
public delegate void DelReadErrOutput(string result);
public partial class Form1 : Form
{
// 2.定义委托事件
public event DelReadStdOutput ReadStdOutput;
public event DelReadErrOutput ReadErrOutput;
public Form1()
{
InitializeComponent();
Init();
}
private void In