protected override void ProcessRecord() { // Create your own ProgressRecord var progressRecord = new ProgressRecord(12, "Running FizzBuzz Twice", "Initial status..."); WriteProgress(progressRecord); for (var i = 1; i <= 3; i++) { // Format progress information any way you like. progressRecord.CurrentOperation = $"Evaluating the number {i}."; progressRecord.PercentComplete = (int)(i / 3d * 100); WriteProgress(progressRecord); var reporter = new ProgressReporter(); var fizzBuzz = new SlowFizzBuzz(); // Start long running task... var task = fizzBuzz.Go(reporter, ThrowException); // Show progress bar and wait until task has completed. Pass in ActivityId of parent. ShowProgressWait(reporter, "I can haz fizzbuzz?", parentActivityId: progressRecord.ActivityId); task.Wait(); } HideProgress(); }
protected override void ProcessRecord() { var reporter = new ProgressReporter(); var fizzBuzz = new SlowFizzBuzz(); // Start long running task... var task = fizzBuzz.Go(reporter, ThrowException); // Show progress bar and wait until task has completed... ShowProgressWait(reporter, "Searching for FizzBuzz..."); task.Wait(); }
protected override void ProcessRecord() { string StatusDescription(ProgressInfo info) => $"Currently processing item {info.CompletedItems} of {info.TotalItems}"; ShowProgress("Running FizzBuzz 3 times"); for (var i = 1; i <= 3; i++) { UpdateProgress(new ProgressInfo($"Run #{i}", i, 3), StatusDescription); var reporter = new ProgressReporter(); var fizzBuzz = new SlowFizzBuzz(); // Start long running task... var task = fizzBuzz.Go(reporter, ThrowException); // Show progress bar and wait until task has completed... ShowProgressWait(reporter, "I can haz fizzbuzz?"); task.Wait(); } HideProgress(); }