We are happy to announce the new monthly 25.11 version of Wordize is published.
What’s new
Added an ability to cancel long running operation using CancellationToken. The code example below demonstrates how to cancel document processing task.
// Arrange
using (CancellationTokenSource cts = new CancellationTokenSource())
{
// Act
Task task = Task.Run(() => { Converter.Create().From(MyDir + "Simple.docx").To(ArtifactsDir + "Processor.ExecuteAsync.pdf").Execute(cts.Token); });
// Simulate user cancel after short delay
Task.Run(() => {
Thread.Sleep(20);
Assert.That(task.IsCompleted, Is.False); // ExSkip
cts.Cancel();
});
try
{
task.Wait();
}
catch(AggregateException ex)
{
Assert.That(ex.InnerException.Message, Is.EqualTo("Document processing is canceled at the document loading stage.")); // ExSkip
Console.WriteLine($"Cancellation reason: '{ex.InnerException.Message}'");
}
}