異步讀取條碼
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剛剛發布