Timeouts
using IronOcr;

int cancel_time = 1000;

// Opens a Large PDF which may need to be cancelled early
IronTesseract ocrTesseract = new IronTesseract() { Language = OcrLanguage.English };
var ocrInput = new OcrInput();
ocrInput.LoadPdf("large-report.pdf");

// Starts a read on the PDF using IronOCR with specified cancel time
OcrReadTask ocrRead = ocrTesseract.ReadAsync(ocrInput, cancel_time);
ocrRead.Wait();
NuGet Download
PM > Install-Package IronOcr
Timeouts

Timeouts

The millisecond timeout parameter of the ReadAsync method provides an optional timeout in milliseconds, after which the OCR read operation will be canceled.

Similar to using a CancellationToken, the ReadAsync timeout parameter also helps with reading large input files in case the program or application becomes stuck.

Please note that the feature is not supported in .NET Framework 4.x.x.

Explore Async OCR Handling with IronOCR in C#
View on GitHub

Ready to Get Started?

Nuget Downloads 6,357,159Version:2026.11just released