private void process_OutputDataReceived(object sender, DataReceivedEventArgs e) { if (e.Data == null) { return; } //debug //Console.WriteLine(e.Data); //end debug if (e.Data.Contains("completed")) { status = Status.Finished; callBack.Invoke(status, 100); } else if (e.Data.Contains("error occurred.")) { status = Status.Failed; callBack.Invoke(status, 100); } Regex legalRegex = new Regex(@"[#S S S S S*]"); if (!legalRegex.IsMatch(e.Data)) { return; } Regex rateRegex = new Regex(@"\d*%"); string rate = rateRegex.Match(e.Data).Value; //TODO 需要增加显示速度功能 if (!String.IsNullOrWhiteSpace(rate)) { callBack(status, int.Parse(rate.Remove(rate.Length - 1))); } }
private void process_Exited(object sender, System.EventArgs e) { Console.WriteLine("process_Exited."); callBack.Invoke(Status.Exit, 100, param); }