예제 #1
0
            /// <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);
                }
            }
예제 #2
0
            /// <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();
            }
        }
예제 #4
0
 /// <summary>Initializes a new ProgressUpdateEventArgsMatcher</summary>
 /// <param name="expected">Expected progress update event arguments</param>
 public ProgressReportEventArgsMatcher(ProgressReportEventArgs expected)
 {
     this.expected = expected;
 }
예제 #5
0
 /// <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);
 }
예제 #8
0
        public void TestCompleteProgress()
        {
            ProgressReportEventArgs zeroProgress = new ProgressReportEventArgs(1.0f);

            Assert.AreEqual(1.0f, zeroProgress.Progress);
        }
예제 #9
0
        public void TestZeroProgress()
        {
            ProgressReportEventArgs zeroProgress = new ProgressReportEventArgs(0.0f);

            Assert.AreEqual(0.0f, zeroProgress.Progress);
        }
예제 #10
0
    /// <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);

    }