IRONSOFTWAREHOME

C# Async & Multithreading Support with IronOCR

Chipego
Chipego Kalinda
Updated: August 26, 2026

IronOCR automatically handles multithreading across all CPU cores and provides async methods like ReadAsync() to perform OCR without blocking your main thread, ensuring responsive applications while processing large documents. For memory-constrained workloads, the MaxDegreeOfParallelism and MultiThreaded properties on IronTesseract cap how many pages are read at once.

Introduction

Processing large volumes of text data efficiently requires both accuracy and speed for OCR operations. This article covers async support and multithreading in IronOCR and Tesseract. Asynchronous programming enables non-blocking OCR execution, keeping applications responsive during text recognition tasks. Multithreading provides parallelism to significantly boost OCR performance. These techniques help developers improve the efficiency and responsiveness of OCR-powered applications.

Quickstart: Use ReadAsync for Effortless Async OCR

Use IronTesseract's ReadAsync method to perform OCR without blocking your main thread. This quickly adds responsive, non-blocking OCR to your application. It works particularly well when processing PDF documents or handling multiple image files simultaneously.

  1. 1Install IronOCR with NuGet Package Manager

    PM > Install-Package IronOcr

  2. 2Copy and run this code snippet.

    var result = await new IronOcr.IronTesseract().ReadAsync("image.png");
    C#
  3. 3Deploy to test on your live environment

    Start using IronOCR in your project today with a free trial
    arrow pointer

How Does Multithreading Work in IronOCR?

IronOCR enhances image processing and OCR reading efficiency through seamless multithreading, requiring no specialized API from developers to get started. IronTesseract automatically leverages all available threads across multiple cores by default, optimizing system resources for swift OCR execution. This built-in multithreading simplifies development and significantly boosts performance by integrating parallelism directly into the OCR workflow. When you need to bound that parallelism - on a memory-capped container or a shared host, for example - see the section on controlling parallelism and memory usage below.

The library's multithreaded Tesseract implementation provides these key advantages:

  • Automatic CPU core utilization: IronOCR detects and uses all available cores without manual configuration, and lets you cap that with MaxDegreeOfParallelism when you need to
  • Thread-safe operations: OCR operations are thread-safe, and a single IronTesseract instance can be shared safely across concurrent reads
  • Tunable memory footprint: Each page read in parallel uses its own native Tesseract engine, so peak memory scales with the degree of parallelism - lower it to trade throughput for a smaller working set
  • Scalable performance: Processing time decreases proportionally with the number of available cores

Here is a multithreaded read example in C#:

using IronOcr;
using System;

var ocr = new IronTesseract();

using (var input = new OcrPdfInput(@"example.pdf"))
{
    var result = ocr.Read(input);
    Console.WriteLine(result.Text);
};

Two properties on IronTesseract let you fine-tune this behavior to match specific performance and memory requirements, covered in the next section. For a different optimization axis - trading a little accuracy for raw speed - see fast OCR configuration.

How Do I Control Parallelism and Memory Usage?

By default, IronTesseract reads as many pages concurrently as the machine has CPU cores, and each concurrent page runs its own native Tesseract engine. Two properties let you bound that when memory matters more than raw throughput:

  • MaxDegreeOfParallelism caps how many pages are OCR'd concurrently within a single Read call. Because each concurrent page costs one engine, lowering it directly lowers peak memory.
  • MultiThreaded turns parallel reading off entirely when set to false, giving the lowest and most predictable footprint. It takes precedence over MaxDegreeOfParallelism.
using IronOcr;

var ocr = new IronTesseract
{
    Language = OcrLanguage.English,
    MaxDegreeOfParallelism = 2 // OCR at most 2 pages at once per Read
};

using var input = new OcrInput();
input.LoadPdf("invoice.pdf");
var result = ocr.Read(input);
C#
Warning: MultiThreaded had no effect in earlier releases - it is now a live setting. Code that set MultiThreaded = false expecting it to be inert will read sequentially after upgrading, with no compiler warning and no exception.
Please note: These properties bound parallelism within a single Read call. Concurrency across multiple documents or multiple Read calls remains your application's responsibility - combine them with the async patterns below.

For default values, the precedence rules between the two properties, guidance on choosing a value, and details of the resolved AccessViolationException in high-volume parallel OCR, see how to limit parallel OCR memory usage.

How Do I Use Async Support in IronOCR?

Asynchronous programming optimizes OCR performance by allowing developers to execute OCR tasks without blocking the main thread. This keeps applications responsive while processing large documents or images for text recognition. Async support enables the system to handle other tasks while OCR operations run in the background. This capability is crucial when implementing OCR progress tracking in user interfaces.

This section covers async support integration in IronOCR, demonstrating different methods to make OCR services non-blocking. IronOCR's async capabilities ensure optimal performance for both desktop applications requiring responsiveness during OCR operations and web services handling multiple concurrent OCR requests.

When Should I Use OcrReadTask Objects?

OcrReadTask objects enhance control and flexibility in OCR processes with IronOCR. These objects encapsulate OCR operations, allowing efficient management of text recognition tasks. This section demonstrates using OcrReadTask objects in your IronOCR workflow and shows how they initiate and optimize OCR tasks. OcrReadTask objects help maximize IronOCR capabilities when orchestrating complex document processing or fine-tuning application responsiveness.

OcrReadTask objects work best when:

  • You need fine-grained control over task execution
  • Implementing abort token functionality for cancellable operations
  • Managing multiple concurrent OCR operations with different priorities
  • Integrating with custom task schedulers or workflow engines
using IronOcr;

IronTesseract ocr = new IronTesseract();

OcrPdfInput largePdf = new OcrPdfInput("chapter1.pdf");

Func<OcrResult> reader = () =>
{
    return ocr.Read(largePdf);
};

OcrReadTask readTask = new OcrReadTask(reader.Invoke);
// Start the OCR task asynchronously
readTask.Start();

// Continue with other tasks while OCR is in progress
DoOtherTasks();

// Wait for the OCR task to complete and retrieve the result
OcrResult result = await Task.Run(() => readTask.Result);

Console.Write($"##### OCR RESULTS ###### \n {result.Text}");

largePdf.Dispose();
readTask.Dispose();

static void DoOtherTasks()
{
    // Simulate other tasks being performed while OCR is in progress
    Console.WriteLine("Performing other tasks...");
    Thread.Sleep(2000); // Simulating work for 2000 milliseconds
}

How Do I Use the ReadAsync Method?

ReadAsync() provides a direct mechanism for initiating OCR operations asynchronously. Without complex threading or task management, developers can integrate asynchronous OCR into their applications. This method prevents the main thread from blocking during OCR tasks, ensuring applications remain responsive.

The ReadAsync method works well for:

  • Desktop applications that need to maintain UI responsiveness
  • Web applications handling multiple simultaneous OCR requests
  • Batch processing scenarios where progress tracking is essential
  • Integration with modern async/await patterns in .NET applications
using IronOcr;
using System;
using System.Threading.Tasks;

IronTesseract ocr = new IronTesseract();

using (OcrPdfInput largePdf = new OcrPdfInput("PDFs/example.pdf"))
{
    var result = await ocr.ReadAsync(largePdf);
    DoOtherTasks();
    Console.Write($"##### OCR RESULTS ###### " +
                $"\n {result.Text}");
}

static void DoOtherTasks()
{
    // Simulate other tasks being performed while OCR is in progress
    Console.WriteLine("Performing other tasks...");
    System.Threading.Thread.Sleep(2000); // Simulating work for 2000 milliseconds
}

Why Should I Use Async and Multithreading with IronOCR?

Combining async support and multithreading in IronOCR provides numerous benefits for modern application development:

Performance Benefits:

  • Improved Throughput: Process multiple documents simultaneously without blocking
  • Better Resource Utilization: Maximize CPU usage across all available cores
  • Reduced Latency: Start processing immediately without waiting for previous operations to complete
  • Scalable Architecture: Handle increasing workloads without architectural changes

Development Benefits:

  • Simplified Code: No need to manage threads manually - IronOCR handles the complexity
  • Modern Patterns: Full support for async/await patterns in Tesseract 5 for .NET
  • Easy Integration: Works seamlessly with existing .NET async infrastructure
  • Maintainable Solutions: Clear, readable code that follows .NET best practices

Multithreading in IronOCR optimizes OCR tasks significantly. The built-in multithreading capabilities, combined with methods like ReadAsync(), simplify handling large volumes of text data. This combination ensures applications remain responsive and efficient, making IronOCR an effective tool for creating high-performance software with streamlined text recognition capabilities. To get started with the complete feature set, check our NuGet package installation guide.

Frequently Asked Questions

What is the ReadAsync method in IronOCR used for?

The ReadAsync method in IronOCR is used to perform asynchronous OCR operations without blocking the main thread, ensuring that applications remain responsive during text recognition tasks.

How does IronOCR handle multithreading?

IronOCR automatically handles multithreading across all CPU cores without requiring any specialized API from developers, optimizing system resources and boosting OCR performance.

What are the main benefits of multithreading in OCR processing?

IronOCR's multithreaded implementation offers automatic CPU core utilization, thread-safe operations, a tunable memory footprint through the MaxDegreeOfParallelism property, and scalable performance where processing time decreases proportionally with available cores.

Why is asynchronous programming important for OCR in IronOCR?

Asynchronous programming in IronOCR allows OCR tasks to be performed without blocking the main thread, keeping applications responsive and enabling the system to handle other tasks while OCR operations run in the background.

Do I need to write special code to enable multithreading for OCR?

No, multithreading is enabled by default and requires no specialized API to get started. The library seamlessly integrates parallelism directly into the OCR workflow, automatically managing threads across multiple cores for optimal performance. If you need to bound that parallelism, set IronTesseract.MaxDegreeOfParallelism or turn it off with MultiThreaded.

How do OcrReadTask objects enhance OCR operations in IronOCR?

OcrReadTask objects in IronOCR provide enhanced control and flexibility, allowing efficient management of text recognition tasks, and are especially useful for managing multiple concurrent operations or cancelling tasks with abort tokens.

How do I limit memory usage when OCRing large batches in parallel?

Set IronTesseract.MaxDegreeOfParallelism to cap how many pages are OCR'd concurrently within a single Read call, or set MultiThreaded to false to read sequentially. Each concurrent page uses its own native Tesseract engine, so lowering the value directly lowers peak memory. See the guide on limiting parallel OCR memory usage for default values and precedence rules.

Does setting MultiThreaded to false actually change anything?

Yes. MultiThreaded had no effect in earlier releases but is now a live setting. Setting it to false reads pages sequentially on a single thread, giving the lowest and most predictable memory footprint, and it overrides MaxDegreeOfParallelism. Code that set this property expecting it to be inert will read sequentially after upgrading.

Is IronOCR fully compatible with .NET 10?

.NET 10 is supported by IronOCR via its latest release version 2025.12. You can install the library using NuGet (Install-Package IronOcr) and run async methods like ReadAsync() under .NET 10 without special configuration.

Ready to Get Started?

Nuget Downloads 6,236,385Version:2026.9just released

Get your FREE

30-day Trial Key instantly.

bullet_checkedNo credit card or account creation required
bullet_testTest in production
without watermarks
bullet_calendar30 days fully
functional product
bullet_support24/5 technical
support during trial
Get your free 30-day Trial Key instantly.
No credit card or account creation required
C# NuGet Library for PDF
Install with NuGet

Version: 2026.9

PM > Install-Package IronOcr
nuget.org/packages/IronOcr/
  1. In Solution Explorer, right-click References, Manage NuGet Packages
  2. Select Browse and search "IronOCR"
  3. Select the package and install
C# PDF DLL
Download DLL

Version: 2026.9

or download Windows Installer here.

  1. Download and unzip IronOCR to a location such as ~/Libs within your Solution directory
  2. In Visual Studio Solution Explorer, right click References. Select Browse, "IronOCR.dll"

Licenses from $999

Key in blue circle

Get your free 30-day Trial Key instantly.

Your trial license will be sent to your email address

No limitations. 100% unlocked. No credit card.

bullet_checkedNo credit card or account creation requiredNo limitations. 100% unlocked. No credit card.
  • Logo Aetna
  • Logo NASA
  • Logo GE
  • Logo Porsche
  • Logo USDA
  • Logo Qatar
Join Millions of Engineers who’ve tried IronPDF
Get Your No-Obligation Consult
Complete the form below or email sales@ironsoftware.com
Your details will always be kept confidential.
Trusted by Millions of Engineers Worldwide
Iron Software's customer logos
Get your free 30-day Trial Key instantly.
No credit card or account creation required