public void CancellationToken() { IAmbientProgress progress = AmbientProgressService.GlobalProgress; progress?.ResetCancellation(); // make a new cancellation in case the source was canceled in this execution context during a previous test if (progress?.GetType().Name == "SubProgress") { Assert.Fail("Progress: " + progress.ItemCurrentlyBeingProcessed + "(" + progress.PortionComplete + ")"); } Assert.AreEqual("Progress", progress?.GetType().Name); CancellationToken token = progress?.CancellationToken ?? default(CancellationToken); Assert.IsFalse(token.IsCancellationRequested); IDisposable subProgress1 = progress?.TrackPart(0.05f, 0.11f); using (AmbientProgressService.GlobalProgress?.TrackPart(0.05f, 0.07f)) { token = AmbientProgressService.GlobalProgress?.CancellationToken ?? default(CancellationToken); Assert.IsFalse(token.IsCancellationRequested); } }