ProcessorSettings

ProcessorSettings class

ProcessorSettings 允许通过多线程提高性能来识别条码

public class ProcessorSettings

特性

姓名描述
MaxAdditionalAllowedThreads { get; set; }指定并行运行代码的最大附加线程数
UseAllCores { get; set; }是使用所有内核所必需的。
UseOnlyThisCoresCount { get; set; }指定要使用的核心数。 您需要将属性“UseAllCores”更改为“false”。

例子

这个示例展示了如何使用 ProcessorSettings 添加最大多线程性能

[C#]
int workerThreads = Environment.ProcessorCount * 2;
int portThreads = Environment.ProcessorCount * 2;
System.Threading.ThreadPool.GetMinThreads(out workerThreads, out portThreads);
System.Threading.ThreadPool.SetMinThreads(Math.Max(workerThreads, Environment.ProcessorCount* 2), portThreads);
System.Threading.ThreadPool.GetMaxThreads(out workerThreads, out portThreads);
System.Threading.ThreadPool.SetMaxThreads(Math.Max(workerThreads, Environment.ProcessorCount* 4), portThreads);
BarCodeReader.ProcessorSettings.MaxAdditionalAllowedThreads = Environment.ProcessorCount* 2;

//这允许将所有内核用于单个 BarCodeReader 调用
BarCodeReader.ProcessorSettings.UseAllCores = true;
//这允许使用当前的核心数
BarCodeReader.ProcessorSettings.UseAllCores = false;
BarCodeReader.ProcessorSettings.UseOnlyThisCoresCount = Math.Max(1, Environment.ProcessorCount / 2);
[VB.NET]
Dim workerThreads As Integer = Environment.ProcessorCount * 2
Dim portThreads As Integer = Environment.ProcessorCount * 2
System.Threading.ThreadPool.GetMinThreads(workerThreads, portThreads)
System.Threading.ThreadPool.SetMinThreads(Math.Max(workerThreads, Environment.ProcessorCount* 2), portThreads)
System.Threading.ThreadPool.GetMaxThreads(workerThreads, portThreads)
System.Threading.ThreadPool.SetMaxThreads(Math.Max(workerThreads, Environment.ProcessorCount* 4), portThreads)
BarCodeReader.ProcessorSettings.MaxAdditionalAllowedThreads = Environment.ProcessorCount* 2

'这允许将所有内核用于单个 BarCodeReader 调用
BarCodeReader.ProcessorSettings.UseAllCores = True
'这允许使用当前的核心数
BarCodeReader.ProcessorSettings.UseAllCores = False
BarCodeReader.ProcessorSettings.UseOnlyThisCoresCount = Math.Max(1, Environment.ProcessorCount / 2)

也可以看看