Interface IProgressDispatcher
Provides progress-reporting dispatch operations for long-running document processing.
public interface IProgressDispatcher
- Extension Methods
Remarks
This interface is available as a sub-interface of the dispatcher, discoverable via DI or by casting an IDispatcher implementation that supports progress reporting.
Follows the ISP (Interface Segregation Principle) to keep the core IDispatcher focused on fire-and-forget and request-response patterns, while progress-reporting operations are opt-in for consumers that need them.
Methods
DispatchWithProgressAsync<TDocument>(TDocument, IMessageContext, IProgress<DocumentProgress>, CancellationToken)
Dispatches a document to a progress-reporting handler.
Task DispatchWithProgressAsync<TDocument>(TDocument document, IMessageContext context, IProgress<DocumentProgress> progress, CancellationToken cancellationToken) where TDocument : IDispatchDocument
Parameters
documentTDocumentThe document to process.
contextIMessageContextContext for the dispatch operation.
progressIProgress<DocumentProgress>The progress reporter for status updates.
cancellationTokenCancellationTokenToken used to cancel the operation.
Returns
- Task
A task that completes when the document has been fully processed.
Type Parameters
TDocumentType of document being dispatched.
Examples
var progress = new Progress<DocumentProgress>(p =>
Console.WriteLine($"{p.PercentComplete:F1}% - {p.CurrentPhase}"));
await progressDispatcher.DispatchWithProgressAsync(
document, context, progress, cancellationToken);
Remarks
This method resolves an IProgressDocumentHandler<TDocument> from the service provider and invokes it with the document and progress reporter. Use this for long-running operations where progress visibility is needed.
The progress parameter receives DocumentProgress
updates as the operation proceeds. Callers can use this for UI updates, logging,
or metrics collection.