/// <summary> /// 翻译进度变化 /// </summary> /// <param name="args"></param> private void Tran_ProcessChanged(WorkProcessEventArgs args) { if (workTimeWatch == null) { workTimeWatch = new Stopwatch(); workTimeWatch.Start(); } if (args.SumCount == (args.CompletedCount + args.FailCount)) { workTimeWatch.Stop(); } else if (args.CompletedCount == 0 && args.FailCount == 0) { workTimeWatch.Restart(); } this.Invoke(new Action(() => { toolProBar.Minimum = 0; toolProBar.Maximum = args.SumCount; toolProBar.Value = args.CompletedCount; lblProcess.Text = string.Format("{0:P0}", args.CompletionRatio); var info = string.Format("翻译进度:已完成{0:P2},{1:N0}/{2:N0},失败数:{3}.", args.CompletionRatio, args.CompletedCount, args.SumCount, args.FailCount); if (args.CompletedCount > 0) { info += string.Format("速度:{0:N2}ms/行.", workTimeWatch.ElapsedMilliseconds / args.CompletedCount); } if (!string.IsNullOrWhiteSpace(args.Message)) { info += "消息:" + args.Message; } toolLableStatus.Text = info; lkSaveFile.Text = "Open:" + Path.GetFileName(tran.GetSaveFileName()); })); }
private void Tran_Completed(WorkProcessEventArgs args) { this.Invoke(new Action(() => { DoWork(false); })); }
private void completed(int sumCount, int successCount, int failCount) { if (Completed == null) { return; } var args = new WorkProcessEventArgs() { SumCount = sumCount, SuccessCount = successCount, FailCount = failCount, }; var d = this.Completed.GetInvocationList(); foreach (BatchWorkItemsChangedHandle item in d) { item.BeginInvoke(args, null, null); } }
private void processChange(int sumCount, int completedCount, int failCount, string message = "") { if (ProcessChanged == null) { return; } var args = new WorkProcessEventArgs() { SumCount = sumCount, SuccessCount = completedCount, FailCount = failCount, Message = message, }; var d = this.ProcessChanged.GetInvocationList(); foreach (BatchWorkItemsChangedHandle item in d) { item.BeginInvoke(args, null, null); } }