Leadtools名前空間 > RasterDefaultsクラス :MaximumThreadCountプロパティ |
public static int MaximumThreadCount {get; set;}
'Declaration
Public Shared Property MaximumThreadCount As Integer
'Usage
Dim value As Integer RasterDefaults.MaximumThreadCount = value value = RasterDefaults.MaximumThreadCount
public static int MaximumThreadCount {get; set;}
<br/>get_MaximumThreadCount();<br/>set_MaximumThreadCount(value);<br/>Object.defineProperty('MaximumThreadCount');
注意:このプロパティは、SilverlightのためにだけLEADTOOLSによって現時点ではサポートされます。
処理がパラレル処理をサポートするならば、デュアルコアマシンまたは2つのCPUで2つのスレッドを使うことは大幅に演算速度を上げます。現時点では、LEADTOOLS JPEG2000エンコーダとデコーダだけは、このプロパティを使っています。より多くのLEADTOOLSエンコーダ/デコーダは、将来このプロパティを使うかもしれません。
設定可能な値は、以下の通りです。
値 | 説明 |
---|---|
0 |
ツールキットは、現在のマシンのCPU/コアの数に基づく実行スレッドの適切な番号を選びます。注意:ツールキットは内部的にこの値を計算して、それを設定します。このプロパティの値を取得したときに0が返されることはありません。 |
1 | 1つのスレッドだけを使います。この場合は、処理用に追加のスレッドは作成されず、すべての操作がメインスレッドで実行されます。 |
2 | 2つのスレッドを使います。必要に応じて、処理用に最大2個のスレッドが作成されます。 |
N | N個のスレッドを使用します。必要に応じて、処理用に最大N個のスレッドが作成されます。 |
ゼロ未満の値は、拒絶されます。大きな値は、CPU/コアの数より、パフォーマンスを増やさないで、リソースの使用状況に処理失敗に至ることができたオーバーロードをもたらすかもしれません。
MaximumThreadCountプロパティはすべてのLEADTOOLSにより用いられるグローバル資源で、スレッドセーフでありません。必要であるならば、必ずプロパティスレッド同期を使うようにするようにしてください。
Imports Leadtools Imports Leadtools.Codecs Imports Leadtools.ImageProcessing Private Sub RasterDefaultsMaximumThreadCountExample() Using codecs As New RasterCodecs 'This is a speed test using multithreading JPEG2000 load, to conduct this test correctly the machine has to have multiple CPUs/Cores. Dim image As RasterImage 'This is just load the binaries. image = codecs.Load(Path.Combine(LEAD_VARS.ImagesDir, "Image1.j2k")) 'Load with MaximumThreadCount equal to the number of CPUs/Cores first. RasterDefaults.MaximumThreadCount = 0 Dim time As DateTime = DateTime.Now image = codecs.Load(Path.Combine(LEAD_VARS.ImagesDir, "Image1.j2k")) Console.WriteLine(" JPEG2000 load time {0} / thread {1}", DateTime.Now - time, RasterDefaults.MaximumThreadCount) 'Load with MaximumThreadCount equal one. RasterDefaults.MaximumThreadCount = 1 time = DateTime.Now image = codecs.Load(Path.Combine(LEAD_VARS.ImagesDir, "Image1.j2k")) Console.WriteLine(" JPEG2000 load time {0} / thread {1}", DateTime.Now - time, RasterDefaults.MaximumThreadCount) image.Dispose() End Using End Sub Public NotInheritable Class LEAD_VARS Public Const ImagesDir As String = "C:\Users\Public\Documents\LEADTOOLS Images" End Class
using Leadtools; using Leadtools.Codecs; private void RasterDefaultsMaximumThreadCountExample() { using (RasterCodecs codecs = new RasterCodecs()) { //This is a speed test using multithreading JPEG2000 load, to conduct this test correctly the machine has to have multiple CPUs/Cores. RasterImage image; //This is just load the binaries. image = codecs.Load(Path.Combine(ImagesPath.Path, "Image1.j2k")); // Load with MaximumThreadCount equal to the number of CPUs/Cores first. RasterDefaults.MaximumThreadCount = 0; DateTime time = DateTime.Now; image = codecs.Load(Path.Combine(ImagesPath.Path,"Image1.j2k")); Console.WriteLine(" JPEG2000 load time {0} / thread {1}", DateTime.Now - time, RasterDefaults.MaximumThreadCount); // Load with MaximumThreadCount equal one. RasterDefaults.MaximumThreadCount = 1; time = DateTime.Now; image = codecs.Load(Path.Combine(ImagesPath.Path, "Image1.j2k")); Console.WriteLine(" JPEG2000 load time {0} / thread {1}", DateTime.Now - time, RasterDefaults.MaximumThreadCount); image.Dispose(); } }