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
imagePaths = new List () { "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. Additionally, the Multithreaded property is set to true to enable parallel processing. The MaxParallelThreads property is also set to 4, instructing the reader to use up to 4 simultaneous threads while balancing performance with system resource usage.
Finally, Read is called, passing both the list of image paths and the configured options to retrieve the BarcodeResults.





