Progress

Progress

This guide shows how to track the progress of long-running document load and save operations.

Long-running load and save operations can report incremental progress through a small callback pair: IDocumentLoadingCallback for loading and IDocumentSavingCallback for saving. Both interfaces follow the same shape — a single Notify(args) method invoked by Aspose.Words FOSS for .NET as the operation proceeds.


Monitoring Document Loading

Implement IDocumentLoadingCallback and assign the implementation to LoadOptions.ProgressCallback before loading a document. During loading, Notify(args) is called with a DocumentLoadingArgs instance whose EstimatedProgress property (a double) reports how far the load has progressed.


Monitoring Document Saving

Implement IDocumentSavingCallback and assign it to SaveOptions.ProgressCallback before calling Document.Save(fileName, saveOptions) (or the stream overload). During saving, Notify(args) receives a DocumentSavingArgs instance, which likewise exposes EstimatedProgress as a double.


Tips and Best Practices

  • DocumentLoadingArgs and DocumentSavingArgs are sealed classes whose only member is EstimatedProgress — treat progress reporting as a lightweight percentage-style signal for UI feedback, not a detailed operation log.
  • Set ProgressCallback on the LoadOptions or SaveOptions instance before passing it to Document(fileName, loadOptions) or Document.Save(fileName, saveOptions) — assigning it afterward has no effect on an operation already in progress.
  • Use a separate callback implementation for loading versus saving; IDocumentLoadingCallback and IDocumentSavingCallback are distinct interfaces even though both expose a single Notify(args) method.

Common Issues

IssueCauseFix
Notify(args) is never calledProgressCallback was not set on the LoadOptions/SaveOptions instance passed to the load or save callAssign ProgressCallback before calling Document(fileName, loadOptions) or Document.Save(fileName, saveOptions)
Progress callback compiles against the wrong argument typeIDocumentLoadingCallback.Notify takes DocumentLoadingArgs; IDocumentSavingCallback.Notify takes DocumentSavingArgs — they are not interchangeableImplement the interface that matches the operation (loading vs. saving)

FAQ

What does EstimatedProgress represent?

It is a double property on DocumentLoadingArgs (during loading) or DocumentSavingArgs (during saving) that reports the operation’s estimated completion progress.

Can I cancel a load or save operation from the progress callback?

Notify(args) on both interfaces takes only the arguments object (DocumentLoadingArgs or DocumentSavingArgs); neither exposes a cancellation flag in this API surface.

Do I need separate callback classes for loading and saving?

You need separate implementations of IDocumentLoadingCallback and IDocumentSavingCallback respectively, since they are different interfaces, though a single class could implement both.


API Reference Summary

Class / InterfaceDescription
IDocumentLoadingCallbackNotify(args) — implement for load-progress notifications
IDocumentSavingCallbackNotify(args) — implement for save-progress notifications
DocumentLoadingArgsEstimatedProgress: double — passed to IDocumentLoadingCallback.Notify
DocumentSavingArgsEstimatedProgress: double — passed to IDocumentSavingCallback.Notify
LoadOptions.ProgressCallbackAttaches an IDocumentLoadingCallback to a load operation
SaveOptions.ProgressCallbackAttaches an IDocumentSavingCallback to a save operation

See Also