异步读取条形码
using IronBarCode;

// Reading many images asynchronously using ReadAsync
string[] imagePaths = new string[] { "image1.png", "image2.png" };
var resultsAsync = BarcodeReader.ReadAsync(imagePaths, new BarcodeReaderOptions() { ExpectMultipleBarcodes = true });

// Reading many PDFs asynchronously using ReadPdfAsync
string[] pdfPaths = new string[] { "doc1.pdf", "doc2.pdf" };
var resultsPdfAsync = BarcodeReader.ReadPdfsAsync(pdfPaths, new PdfBarcodeReaderOptions() { ExpectMultipleBarcodes = true, Scale = 3, DPI = 300 });
NuGet下载
PM > Install-Package BarCode
异步读取条形码

异步读取条形码

我们可以使用BarcodeReader类来读取条形码。 最简单的方法是使用BarcodeReader.Read方法。 IronBarcode还具有用于多线程异步编程的ReadAsync方法。

关键点

  • 同步与异步方法
    • Read方法在需要立即结果时使用起来很简单,并在主线程上调用。
    • ReadAsync方法用于异步执行,允许程序在等待条形码读取完成时继续执行其他任务。
  • BarcodeReaderOptions
    • ExpectMultipleBarcodes: 如果设置为true,读取器将在图像中寻找多个条形码。
    • Speed: 使用ReadingSpeed枚举设置读取速度与准确性之间的权衡。
    • Multithreaded: 启用多线程读取,这对于快速处理大量图像非常有用。
探索异步和多线程条形码读取
在GitHub上查看

准备开始了吗?

NuGet 下载量 2,575,633版本:2026.11刚刚发布