/// <summary>Fires the progress update event</summary> /// <param name="eventArguments">Progress to report (ranging from 0.0 to 1.0)</param> /// <remarks> /// Informs the observers of this transaction about the achieved progress. /// Allows for classes derived from the transaction class to easily provide /// a custom event arguments class that has been derived from the /// transaction's ProgressUpdateEventArgs class. /// </remarks> protected virtual void OnAsyncProgressChanged(ProgressReportEventArgs eventArguments) { EventHandler <ProgressReportEventArgs> copy = AsyncProgressChanged; if (copy != null) { copy(this, eventArguments); } }
/// <summary> /// Called by NMock to verfiy the ProgressUpdateEventArgs match the expected value /// </summary> /// <param name="actualAsObject">Actual value to compare to the expected value</param> /// <returns> /// True if the actual value matches the expected value; otherwise false /// </returns> public override bool Matches(object actualAsObject) { ProgressReportEventArgs actual = (actualAsObject as ProgressReportEventArgs); if (actual == null) { return(false); } return(actual.Progress == this.expected.Progress); }
/// <summary>Called when the progress of the observed transaction changes</summary> /// <param name="sender">Transaction whose progress has changed</param> /// <param name="arguments">Contains the updated progress</param> private void asyncProgressChanged(object sender, ProgressReportEventArgs arguments) { this.progress = arguments.Progress; ReportDelegate savedProgressUpdateCallback = this.progressUpdateCallback; if (savedProgressUpdateCallback != null) { savedProgressUpdateCallback(); } }
/// <summary>Initializes a new ProgressUpdateEventArgsMatcher</summary> /// <param name="expected">Expected progress update event arguments</param> public ProgressReportEventArgsMatcher(ProgressReportEventArgs expected) { this.expected = expected; }
/// <summary> /// Called when the summed progressed of the tracked transaction has changed /// </summary> /// <param name="sender">Transaction whose progress has changed</param> /// <param name="arguments">Contains the progress achieved by the transaction</param> private void asyncProgressUpdated( object sender, ProgressReportEventArgs arguments ) { AsyncSetValue(arguments.Progress); }
/// <summary>Initializes a new ProgressUpdateEventArgsMatcher </summary> /// <param name="expected">Expected progress update event arguments</param> public ProgressUpdateEventArgsMatcher(ProgressReportEventArgs expected) { this.expected = expected; }
/// <summary>Fires the progress update event</summary> /// <param name="eventArguments">Progress to report (ranging from 0.0 to 1.0)</param> /// <remarks> /// Informs the observers of this transaction about the achieved progress. /// Allows for classes derived from the transaction class to easily provide /// a custom event arguments class that has been derived from the /// transaction's ProgressUpdateEventArgs class. /// </remarks> protected virtual void OnAsyncProgressChanged(ProgressReportEventArgs eventArguments) { EventHandler<ProgressReportEventArgs> copy = AsyncProgressChanged; if(copy != null) copy(this, eventArguments); }
public void TestCompleteProgress() { ProgressReportEventArgs zeroProgress = new ProgressReportEventArgs(1.0f); Assert.AreEqual(1.0f, zeroProgress.Progress); }
public void TestZeroProgress() { ProgressReportEventArgs zeroProgress = new ProgressReportEventArgs(0.0f); Assert.AreEqual(0.0f, zeroProgress.Progress); }
/// <summary>Called when the tracked transaction's progress updates</summary> /// <param name="sender">Transaction whose progress has been updated</param> /// <param name="arguments"> /// Contains the new progress achieved by the transaction /// </param> private void asyncProgressChanged(object sender, ProgressReportEventArgs arguments) { // See if this is the first progress update we're receiving. If yes, we need to // switch the progress bar from marquee into its normal mode! int haveProgress = Interlocked.Exchange(ref this.areProgressUpdatesIncoming, 1); if(haveProgress == 0) { this.progressBar.BeginInvoke( (MethodInvoker)delegate() { this.progressBar.Style = ProgressBarStyle.Blocks; } ); } // Send the new progress to the progress bar this.progressBar.AsyncSetValue(arguments.Progress); }