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
T
The 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
handler
Action<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
handler
Action<T>A handler to invoke for each reported progress value. It is possible that this handler instance could be invoked concurrently with itself.
joinableTaskFactory
JoinableTaskFactoryA JoinableTaskFactory instance that can be used to mitigate deadlocks when WaitAsync(CancellationToken) is called and the
handler
requires the main thread.
ProgressWithCompletion(Func<T, Task>)
Initializes a new instance of the ProgressWithCompletion<T> class.
public ProgressWithCompletion(Func<T, Task> handler)
Parameters
handler
Func<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
handler
Func<T, Task>A handler to invoke for each reported progress value. It is possible that this handler instance could be invoked concurrently with itself.
joinableTaskFactory
JoinableTaskFactoryA JoinableTaskFactory instance that can be used to mitigate deadlocks when WaitAsync(CancellationToken) is called and the
handler
requires the main thread.
Methods
Report(T)
Receives a progress update.
protected virtual void Report(T value)
Parameters
value
TThe 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
cancellationToken
CancellationTokenA cancellation token.
Returns
- Task
A task that completes when all progress is complete.