ThreadPool.GetMinThreads メソッド
アセンブリ: mscorlib (mscorlib.dll 内)

Public Shared Sub GetMinThreads ( _ <OutAttribute> ByRef workerThreads As Integer, _ <OutAttribute> ByRef completionPortThreads As Integer _ )
Dim workerThreads As Integer Dim completionPortThreads As Integer ThreadPool.GetMinThreads(workerThreads, completionPortThreads)
public: static void GetMinThreads ( [OutAttribute] int% workerThreads, [OutAttribute] int% completionPortThreads )
public static void GetMinThreads ( /** @attribute OutAttribute() */ /** @ref */ int workerThreads, /** @attribute OutAttribute() */ /** @ref */ int completionPortThreads )

スレッド プール内にアイドル状態のスレッドを保持するのは、スレッド プールのスレッドが要求された場合に、要求にすばやく応じるためです。ワーカー スレッドおよび非同期 I/O スレッドに対して、別個に最少数が保持されます。アイドル状態のスレッドが最小数を超えると、システム リソースを節約するために余分なスレッドが終了されます。アイドル状態のスレッドの保持はバックグラウンド タスクが担当します。
GetMinThreads を呼び出すと、workerThreads に指定した変数には、スレッド プールに保持されているアイドル状態のワーカー スレッドの最小数が格納され、completionPortThreads に指定した変数には、スレッド プールに保持されているアイドル状態の非同期 I/O スレッドの最小数が格納されます。
![]() |
---|
GetMinThreads と SetMinThreads は、コンピュータのプロセッサ数に関係なしに、スレッド ツールに保持されるアイドル状態のスレッドの総数を取得および設定します。 |

アイドル状態のワーカー スレッドの最小数を 4 に設定し、アイドル状態の非同期 I/O 完了スレッドの最小数については元の値を保持する例を次に示します。
Imports System Imports System.Threading Public Class Test <MTAThread> _ Public Shared Sub Main() Dim minWorker, minIOC As Integer ' Get the current settings. ThreadPool.GetMinThreads(minWorker, minIOC) ' Change the minimum number of worker threads to four, but ' keep the old setting for minimum asynchronous I/O ' completion threads. If ThreadPool.SetMinThreads(4, minIOC) Then ' The minimum number of threads was set successfully. Else ' The minimum number of threads was not changed. End If End Sub End Class
using System; using System.Threading; public class Test { public static void Main() { int minWorker, minIOC; // Get the current settings. ThreadPool.GetMinThreads(out minWorker, out minIOC); // Change the minimum number of worker threads to four, but // keep the old setting for minimum asynchronous I/O // completion threads. if (ThreadPool.SetMinThreads(4, minIOC)) { // The minimum number of threads was set successfully. } else { // The minimum number of threads was not changed. } } }
using namespace System; using namespace System::Threading; int main() { int minWorker; int minIOC; // Get the current settings. ThreadPool::GetMinThreads( minWorker, minIOC ); // Change the minimum number of worker threads to four, but // keep the old setting for minimum asynchronous I/O // completion threads. if ( ThreadPool::SetMinThreads( 4, minIOC ) ) { // The minimum number of threads was set successfully. } else { // The minimum number of threads was not changed. } }
import System.*; import System.Threading.*; import System.Threading.Thread; public class Test { public static void main(String[] args) { int minWorker = 0; int minIOC = 0; // Get the current settings. ThreadPool.GetMinThreads(minWorker, minIOC); // Change the minimum number of worker threads to four, but // keep the old setting for minimum asynchronous I/O // completion threads. if (ThreadPool.SetMinThreads(4, minIOC)) { // The minimum number of threads was set successfully. } else { // The minimum number of threads was not changed. } } //main } //Test

Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


Weblioに収録されているすべての辞書からThreadPool.GetMinThreads メソッドを検索する場合は、下記のリンクをクリックしてください。

- ThreadPool.GetMinThreads メソッドのページへのリンク