private void OnProgressUpdated(object sender, ProgressUpdateEventArgs e) { var stopwatch = GetStopwatch(e.FileEntry); if (e.BytesWritten == 0) { stopwatch.Reset(); stopwatch.Start(); } var message = $"Downloaded {e.BytesWritten}"; message = e.Length > 0 ? $"{message} of {e.Length} byte(s)" : $"{message} byte(s)"; var seconds = stopwatch.Elapsed.TotalSeconds; if (seconds > 0 && e.BytesWritten > 0) { var bytesPerSecond = e.BytesWritten / seconds; var bandwidth = PrettyPrintBandwidth(bytesPerSecond); message = $"{message} ({bandwidth})"; } message = $"{e.FileEntry.Path}: {message}"; if (e.BytesWritten == e.Length) { RemoveStopwatch(e.FileEntry); } Output.WriteLine(message); }
void AppInstallManager_OnProgressEvent(object sender, ProgressUpdateEventArgs e) { UpdateUIThreadSafe(() => { Progress = (int)e.Progress.percentage; }); }
public void OnProgressUpdate(object sender, ProgressUpdateEventArgs e) { if (ProgressUpdate != null) { ProgressUpdate(sender, e); } }
// Wrap event invocations inside a protected virtual method protected virtual void OnProgressUpdateEventHandler(ProgressUpdateEventArgs e) { // Make a temporary copy of the event to avoid possibility of // a race condition if the last subscriber unsubscribes // immediately after the null check and before the event is raised. ProgressUpdateEventHandler?.Invoke(this, e); }
private void OnProgressUpdate(object sender, ProgressUpdateEventArgs e) { if (ProgressUpdate != null) { ProgressUpdate(sender, e); } }
private void UpdateProgress(object sender, ProgressUpdateEventArgs e) { // Unblock the waiting thread, if there was a cancel or error lock (CHANGE_EVENT_LOCK) { // Keep track of last progress, but do not overwrite an error, unless // this is a MultiProgressStatus, where useful information may be added // even after the first error. var multiProgress = e.Progress as MultiProgressStatus; if (multiProgress != null || LastProgress == null || !LastProgress.IsError) { // Keep MultiProgressStatus around, even when it is completed LastProgress = multiProgress != null || !e.Progress.IsComplete ? e.Progress : null; } if (e.Progress.IsCanceled || e.Progress.IsError) { Monitor.Pulse(CHANGE_EVENT_LOCK); } } if (ProgressMonitor != null) { ProgressMonitor.UpdateProgress(e.Progress); } }
protected virtual void OnProgressUpdate(object sender, ProgressUpdateEventArgs e) { if (ProgressUpdate != null) { ProgressUpdate(sender, e); } }
private void update_ProgressUpdate(object sender, ProgressUpdateEventArgs e) { Invoke((MethodInvoker) delegate { pbProgress.Value = e.ProgressPercentage; lblStatus.Text = string.Format("Status: Downloading {0} / {1}...", e.Current, e.Max); }); }
void ReportProgress(int percentage) { var progressUpdate = new ProgressUpdateEventArgs(ProgressTypes.HandHistoriesDirectoryImport, percentage); _eventAggregator .GetEvent <ProgressUpdateEvent>() .Publish(progressUpdate); }
private void OnImportProgressUpdate(object sender, ProgressUpdateEventArgs e) { Application.Invoke(delegate { progress.Fraction = e.Completed / 100.0; progress.Text = string.Format(S._("{0:0}% completed."), e.Completed); }); }
void ReportProgress(int percentage) { var progressUpdate = new ProgressUpdateEventArgs(ProgressTypes.DatabaseImport, percentage); _eventAggregator .GetEvent <ProgressUpdateEvent>() .Publish(progressUpdate); }
public UpdateProgressResponse UpdateProgress(IProgressStatus status) { if (ProgressUpdateEvent != null) { var args = new ProgressUpdateEventArgs(status); ProgressUpdateEvent(this, args); return(args.Response); } return(UpdateProgressResponse.normal); }
private void LogParseTask_LogProcessed(object sender, ProgressUpdateEventArgs e) { var task = (ParseTask)sender; if (!(task.State == TaskStates.Completed)) { var parseResult = task.Results[e.Filepath]; UpdateResultGroups(parseResult.TimestampGroups, parseResult); } ProgressUpdate.Invoke(sender, new ProgressUpdateEventArgs(task.Id, e.Filepath, e.Percentage, e.State)); }
void batchjob_OnProgressTotalUpdate(object sender, ProgressUpdateEventArgs e) { this.CurrentOp = e.CurrentOp; this.TotalOps = e.TotalOps; this.SubItems[5].Text = e.Message; if (this.ListView != null) { this.ListView.Invalidate(this.SubItems[PROGRESSBAR_COLUMN].Bounds); } InvalidateTreeview(); }
void HandleProgressUpdateEvent(ProgressUpdateEventArgs arg) { switch (arg.ProgressType) { case ProgressTypes.HandHistoriesDirectoryImport: HandHistoriesDirectoryImportProgress.PercentCompleted = arg.PercentCompleted; break; case ProgressTypes.DatabaseImport: DatabaseImportProgress.PercentCompleted = arg.PercentCompleted; break; } }
private void OnPatchingProgressUpdate(object sender, ProgressUpdateEventArgs e) { PatchingTask task = e.State as PatchingTask; if (task != null) { Invoke((MethodInvoker) delegate() { ListViewItem item = _patchTable[task]; UpdatePatchingStatus(task, item, e.Current, e.Max, e.ProgressPercentage, "Patching..."); }); } }
private void OnDownloadStateProgressUpdate(object sender, ProgressUpdateEventArgs e) { DownloadTask state = e.State as DownloadTask; if (state != null) { Invoke((MethodInvoker) delegate() { ListViewItem item = _downloadTable[state]; UpdateDownloadStatus(state, item, e.Current, e.Max, e.ProgressPercentage, "Downloading..."); }); } }
private void OnExtractionProgressUpdate(object sender, ProgressUpdateEventArgs e) { ExtractionTask task = e.State as ExtractionTask; if (task != null) { Invoke((MethodInvoker) delegate() { ListViewItem item = _extractionTable[task]; UpdateExtractionStatus(task, item, e.Current, e.Max, e.ProgressPercentage, "Extracting..."); }); } }
/// <summary> /// Updates the progress bar with the updated progress. /// </summary> /// <param name="sender">The sender of the event.</param> /// <param name="args">Consists of event parameters.</param> internal void OnProgressUpdate(object sender, ProgressUpdateEventArgs args) { var progress = _controller.ProgressManager.UpdateProgress(sender, args.Progress); if (_controller.ProgressManager.Exchange(progress).Equals(ProgressManager.Sentinel)) { Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => { var totalProgress = _controller.ProgressManager.Exchange(ProgressManager.Sentinel); if (totalProgress > ProgressBar.Value) { ProgressBar.Value = totalProgress; } }).AsTask().Forget(); } }
/// <summary> /// Handles the UpdatedProgress event of the steps control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="RT2020.SettingsMonthEndCommon.ProgressUpdateEventArgs"/> instance containing the event data.</param> void steps_UpdatedProgress(object sender, ProgressUpdateEventArgs e) { txtProgessMessage.Text = e.Message; txtProgessMessage.Update(); if (e.Position >= e.Total) { e.Position = e.Position / e.Total; } progressBar.Value = e.Position; progressBar.Maximum = e.Total; progressBar.Update(); this.Update(); }
private void JobOnProgressUpdate(object sender, ProgressUpdateEventArgs e) { this.InvokeIfRequired(() => { if (e.Message != null) { listLog.Items.Add($"{e.Message}"); listLog.SelectedIndex = listLog.Items.Count - 1; listLog.SelectedIndex = -1; } lblFilesProcessed.Text = e.FilesProcessed.ToString(); lblFileBytesProcessed.Text = e.FilesSizeProcessed.ToString(); lblFoldersProcessed.Text = e.FoldersProcessed.ToString(); }); }
private void FileSystem_OnProgress(object sender, ProgressUpdateEventArgs e) { try { if (e.Percent == _prevpercent) { return; } DisplayProgress(e.Percent); _prevpercent = e.Percent; } catch (Exception ex) { AppendEventLog("FileSystem_OnProgress Error: " + ex.Message); } }
/// <summary> /// Raises the <see cref="E:ProgressUpdateHandler" /> event. /// </summary> /// <param name="e">The <see cref="ProgressUpdateEventArgs"/> instance containing the event data.</param> protected void OnProgressUpdateHandler(ProgressUpdateEventArgs e) { try { pbMain.Visible = true; lblProgress.Visible = true; pbMain.Maximum = e.Total; pbMain.Value = e.Current; lblProgress.Text = e.Current + " of " + e.Total + " processed"; Application.DoEvents(); } catch (Exception ex) { this.Cursor = Cursors.Default; MessageBox.Show(ex.Message, Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void UpdateProgress(object sender, ProgressUpdateEventArgs e) { // Unblock the waiting thread, if there was a cancel or error lock (CHANGE_EVENT_LOCK) { // Keep track of last progress, but do not overwrite an error if (LastProgress == null || !LastProgress.IsError) { LastProgress = (!e.Progress.IsComplete ? e.Progress : null); } if (e.Progress.IsCanceled || e.Progress.IsError) { Monitor.Pulse(CHANGE_EVENT_LOCK); } } if (ProgressMonitor != null) { ProgressMonitor.UpdateProgress(e.Progress); } }
} // end StartTask #endregion #region Event Handlers #region UpdateProgress /// <summary> /// UpdateProgress event for the Process, which is used to handle updating the /// progress of the Task. /// </summary> /// <param name="sender"></param> /// <param name="e">Progress Update Event Arguments, which include the Progress Message /// and Progress Value.</param> void UpdateProgress(object sender, ProgressUpdateEventArgs e) { // InvokeRequired required compares the thread ID of the calling thread to the thread // ID of the creating thread. If these threads are different, it returns true. if (_lblProgress.InvokeRequired) { Invoke(new SetProgressTextHandler(SetProgressText), new object[] { e.ProgressMsg }); } // end if else { _lblProgress.Text = e.ProgressMsg; } // end else if (_prgTaskProgress.InvokeRequired) { Invoke(new SetProgressValueHandler(SetProgressValue), new object[] { e.ProgressValue }); } // end if else { _prgTaskProgress.Value = e.ProgressValue; } // end else } // end UpdateProgress
private void UpdateProgress(object sender, ProgressUpdateEventArgs e) { var status = e.Progress; if (ProgressMonitor != null) { ProgressMonitor.UpdateProgress(status); } // Unblock the waiting thread, if there was a cancel or error lock (CHANGE_EVENT_LOCK) { // Keep track of last progress, but do not overwrite an error, unless // this is a MultiProgressStatus, where useful information may be added // even after the first error. if (status is MultiProgressStatus) { // But avoid overwriting a final progress with a non-final progress for the same operation if (IsProgressIdChanging(status) || !LastProgress.IsFinal) { LastProgress = status; } } else { if (IsProgressIdChanging(status) || !LastProgress.IsError) { LastProgress = !status.IsComplete ? status : null; } } if (status.IsCanceled || status.IsError) { Monitor.Pulse(CHANGE_EVENT_LOCK); } } }
void progressServiceOnUpdate(object sender, ProgressUpdateEventArgs e) { this.ProgressValue = e.Progress; this.ProgressText = e.ProgressText; }
private void OnProgressUpdated(ProgressUpdateEventArgs e) { ProgressUpdated?.Invoke(this, e); }
protected virtual void OnProgressUpdate(object sender, ProgressUpdateEventArgs e) { if (ProgressUpdate != null) { ProgressUpdate(sender, e); } }
private void Run_ProgressUpdate(object sender, ProgressUpdateEventArgs e) { _dispatcher.BeginInvoke(new Action(() => { Progress = e.Progress; ProgressTotal = e.Total; ProgressMessage = e.Message; })); }
/// <summary> /// Handles the UpdatedProgress event of the objStep control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="RT2020.SettingsMonthEndCommon.ProgressUpdateEventArgs"/> instance containing the event data.</param> void objStep_UpdatedProgress(object sender, ProgressUpdateEventArgs e) { UpdatedProgress(this, new ProgressUpdateEventArgs(e.Message, e.Position, e.Total)); }
private void DoUpdate(object Sender, ProgressUpdateEventArgs E) { SetStatus(E.ProgressShortDescription, E.ProgressDescription); SetProgress(E.Progress); }
void OnRenderProgressUpdate(object Sender, ProgressUpdateEventArgs E) { Console.SetCursorPosition(0, Console.CursorTop); Console.Write(E.ProgressDescription); }