異步讀取條碼
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 Download
PM > Install-Package BarCode
異步讀取條碼

異步讀取條碼

我們可以使用BarcodeReader類別讀取條碼。 最簡單的方法是使用BarcodeReader.Read方法。 IronBarcode也有一個ReadAsync方法適用於多執行緒非同步程式設計。

關鍵要點

  • 同步與非同步方法

    • 當需要立即結果時,Read方法適合使用,並於主執行緒上呼叫。
    • ReadAsync方法適用於非同步執行,允許程式在等待條碼讀取完成的同時繼續執行其他任務。
  • BarcodeReaderOptions

    • ExpectMultipleBarcodes: 如果設置為true,讀取器將在影像中尋找多個條碼。
    • EnhanceAccuracy: 提高準確性但以速度為代價。
    • SpeedUp: 提高讀取效率,這可能在快速處理大量影像時有用。 但是,如果設置為true,這可能會降低準確性。
探索非同步與多執行緒條碼讀取
在 GitHub 上查看

準備好開始了嗎?

Nuget Downloads 2,540,041版本:2026.11剛剛發布