Set Max Parallel Threads
using IronBarCode;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;

List<string> imagePaths = new List<string>() { "sample_a.png", "sample_b.png" };

// Barcode reading options
BarcodeReaderOptions options = new BarcodeReaderOptions()
{
    // Set Max threads to 4
    Multithreaded = true,
    MaxParallelThreads = 4,
};

// Read barcode with multithreaded enabled
BarcodeResults results = BarcodeReader.Read(imagePaths, options);

NuGet Download
PM > Install-Package BarCode
Set Max Parallel Threads

Set Max Parallel Threads

Processing large batches of documents or images sequentially can be time-consuming, creating bottlenecks in high-volume applications. Using parallel threads allows the application to process multiple images simultaneously, significantly reducing overall execution time. In this code example, we will demonstrate how to configure IronBarcode to use multi-threading for faster batch barcode reading.

5-step guide for using parallel threads to read barcode

  • using IronBarCode;
  • using System.Threading.Tasks;
  • List<string> imagePaths = new List<string>() { "sample_a.png", "sample_b.png" };
  • BarcodeReaderOptions options = new BarcodeReaderOptions(){ Multithreaded = true, MaxParallelThreads = 4 };
  • BarcodeResults results = BarcodeReader.Read(imagePaths, options);

Code Explanation

First, the IronBarcode library and the threading namespace are imported, and a List<string> containing the file paths of the images to be processed is defined. In the example above, "sample_a.png" and "sample_b.png" are prepared for scanning.

Next, a BarcodeReaderOptions object is instantiated to configure the scanning behavior. Multithreaded Additionally, the ParallelProcessing property is set to true to enable parallel processing. Multithreaded The MaxDegreeOfParallelism property is also set to 4, instructing the reader to use up to 4 simultaneous threads while balancing performance with system resource usage. MaxParallelThreads MaxParallelThreads Read BarcodeReader.Read

Finally, ReadBarcodes is called, passing both the list of image paths and the configured options to retrieve the BarcodeResults.

Learn to set max parallel threads with IronBarcode

Ready to Get Started?

Nuget Downloads 2,540,041Version:2026.11just released