Class ProgressWithCompletion<T>
- Namespace
- Microsoft.VisualStudio.Threading
- Assembly
- Microsoft.VisualStudio.Threading.dll
An incremental progress reporting mechanism that also allows asynchronous awaiting for all reports to be processed.
public class ProgressWithCompletion<T> : IProgress<T>
Type Parameters
TThe type of message sent in progress updates.
- Inheritance
-
ProgressWithCompletion<T>
- Implements
-
IProgress<T>
- Inherited Members
Constructors
ProgressWithCompletion(Action<T>)
Initializes a new instance of the ProgressWithCompletion<T> class.
public ProgressWithCompletion(Action<T> handler)
Parameters
handlerAction<T>A handler to invoke for each reported progress value. Depending on the SynchronizationContext instance that is captured when this constructor is invoked, it is possible that this handler instance could be invoked concurrently with itself.
ProgressWithCompletion(Action<T>, JoinableTaskFactory?)
Initializes a new instance of the ProgressWithCompletion<T> class.
public ProgressWithCompletion(Action<T> handler, JoinableTaskFactory? joinableTaskFactory)
Parameters
handlerAction<T>A handler to invoke for each reported progress value. It is possible that this handler instance could be invoked concurrently with itself.
joinableTaskFactoryJoinableTaskFactoryA JoinableTaskFactory instance that can be used to mitigate deadlocks when WaitAsync(CancellationToken) is called and the
handlerrequires the main thread.
ProgressWithCompletion(Func<T, Task>)
Initializes a new instance of the ProgressWithCompletion<T> class.
public ProgressWithCompletion(Func<T, Task> handler)
Parameters
handlerFunc<T, Task>A handler to invoke for each reported progress value. Depending on the SynchronizationContext instance that is captured when this constructor is invoked, it is possible that this handler instance could be invoked concurrently with itself.
ProgressWithCompletion(Func<T, Task>, JoinableTaskFactory?)
Initializes a new instance of the ProgressWithCompletion<T> class.
public ProgressWithCompletion(Func<T, Task> handler, JoinableTaskFactory? joinableTaskFactory)
Parameters
handlerFunc<T, Task>A handler to invoke for each reported progress value. It is possible that this handler instance could be invoked concurrently with itself.
joinableTaskFactoryJoinableTaskFactoryA JoinableTaskFactory instance that can be used to mitigate deadlocks when WaitAsync(CancellationToken) is called and the
handlerrequires the main thread.
Methods
Report(T)
Receives a progress update.
protected virtual void Report(T value)
Parameters
valueTThe value representing the updated progress.
WaitAsync()
Returns a task that completes when all reported progress has executed.
public Task WaitAsync()
Returns
- Task
A task that completes when all progress is complete.
WaitAsync(CancellationToken)
Returns a task that completes when all reported progress has executed.
public Task WaitAsync(CancellationToken cancellationToken)
Parameters
cancellationTokenCancellationTokenA cancellation token.
Returns
- Task
A task that completes when all progress is complete.