最大並列スレッドの設定
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ダウンロード
PM > Install-Package BarCode
最大並列スレッドの設定

最大並列スレッドの設定

大量の文書や画像を連続して処理するのは時間がかかり、大量のアプリケーションでボトルネックになることがあります。 並列スレッドを使用することで、アプリケーションは複数の画像を同時に処理でき、全体の実行時間を大幅に短縮できます。このコード例では、バーコードのバッチ読み取りを高速化するためにIronBarcodeをマルチスレッドに設定する方法を説明します。

並列スレッドを使用してバーコードを読むための5ステップガイド

  • 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);

コードの説明

最初に、IronBarcodeライブラリとスレッドのnamespaceをインポートし、処理する画像のファイルパスを含むList<string>を定義します。 上記の例では、「sample_a.png」と「sample_b.png」がスキャン用に用意されています。

次に、スキャンの動作を設定するためにBarcodeReaderOptionsオブジェクトがインスタンス化されます。 Multithreaded 加えて、ParallelProcessing プロパティがtrueに設定されており、並列処理を有効にしています。 Multithreaded MaxDegreeOfParallelism プロパティも4に設定されており、性能とシステムリソースの使用をバランスさせつつ、最大4つのスレッドを同時に使用するよう指示しています。 MaxParallelThreads MaxParallelThreads Read BarcodeReader.Read

最後に、ReadBarcodes が呼び出され、画像パスのリストと設定されたオプションの両方が渡されて、BarcodeResults を取得します。

IronBarcodeで最大並列スレッドを設定する方法を学ぶ

準備はできましたか?

NuGetダウンロード数 2,575,633バージョン:2026.11ちょうどリリースされました