private async void UpdateProgress(object sender, ConvertProgressEventArgs e) { var processed = int.Parse(e.Processed.TotalMilliseconds.ToString()) * 100 / int.Parse(e.TotalDuration.TotalMilliseconds.ToString()); //progressBar1.Step await Task.Run(() => { backgroundWorker1.ReportProgress(processed); }); }
internal void ParseLine(string line) { if (this.Enabled) { TimeSpan totalDuration = (this.lastProgressArgs != null) ? this.lastProgressArgs.TotalDuration : TimeSpan.Zero; Match match = DurationRegex.Match(line); if (match.Success) { TimeSpan zero = TimeSpan.Zero; if (TimeSpan.TryParse(match.Groups["duration"].Value, out zero)) { TimeSpan span3 = totalDuration.Add(zero); this.lastProgressArgs = new ConvertProgressEventArgs(TimeSpan.Zero, span3); } } Match match2 = ProgressRegex.Match(line); if (match2.Success) { TimeSpan zero = TimeSpan.Zero; if (TimeSpan.TryParse(match2.Groups["progress"].Value, out zero)) { if (this.progressEventCount == 0) { totalDuration = this.CorrectDuration(totalDuration); } this.lastProgressArgs = new ConvertProgressEventArgs(zero, (totalDuration != TimeSpan.Zero) ? totalDuration : zero); this.ProgressCallback(this.lastProgressArgs); this.progressEventCount++; } } } }
internal void OnConvertProgress(ConvertProgressEventArgs args) { if (this.ConvertProgress != null) { this.ConvertProgress(this, args); } }
private void UpdateProgress(object sender, ConvertProgressEventArgs e) { this.pbProgress.Value = (int)Math.Ceiling((e.Processed.Milliseconds / (double)this.totalSeconds) * 100); //Or whatever calculation you want this.pbTotalProgress.Value = (int)Math.Ceiling((this.processedItem / (double)totalItem) * 100); }
internal void Reset() { this.progressEventCount = 0; this.lastProgressArgs = null; }