ThreadPool.GetAvailableThreads(Int32, Int32) ThreadPool.GetAvailableThreads(Int32, Int32) ThreadPool.GetAvailableThreads(Int32, Int32) ThreadPool.GetAvailableThreads(Int32, Int32) Method

Definizione

Recupera la differenza tra il numero massimo di thread del pool di thread restituito dal metodo GetMaxThreads(Int32, Int32) e il numero attualmente attivo.Retrieves the difference between the maximum number of thread pool threads returned by the GetMaxThreads(Int32, Int32) method, and the number currently active.

public:
 static void GetAvailableThreads([Runtime::InteropServices::Out] int % workerThreads, [Runtime::InteropServices::Out] int % completionPortThreads);
public static void GetAvailableThreads (out int workerThreads, out int completionPortThreads);
static member GetAvailableThreads : int * int -> unit
Public Shared Sub GetAvailableThreads (ByRef workerThreads As Integer, ByRef completionPortThreads As Integer)

Parametri

workerThreads
Int32 Int32 Int32 Int32

Numero di thread di lavoro disponibili.The number of available worker threads.

completionPortThreads
Int32 Int32 Int32 Int32

Numero di thread I/O asincroni disponibili.The number of available asynchronous I/O threads.

Esempi

Nell'esempio seguente viene visualizzato il numero di thread di lavoro e thread di I/O disponibili quando viene avviata un'app semplice.The following example displays the number of worker threads and I/O threads available when a simple app is started.

using System;
using System.Threading;

public class Example
{
   public static void Main()
   {
      int worker = 0;
      int io = 0;
      ThreadPool.GetAvailableThreads(out worker, out io);
      
      Console.WriteLine("Thread pool threads available at startup: ");
      Console.WriteLine("   Worker threads: {0:N0}", worker);
      Console.WriteLine("   Asynchronous I/O threads: {0:N0}", io);
   }
}
// The example displays output like the following:
//    Thread pool threads available at startup:
//       Worker threads: 32,767
//       Asynchronous I/O threads: 1,000
Imports System.Threading

 Module Example
   Public Sub Main()
      Dim worker As Integer = 0
      Dim io As Integer = 0
      ThreadPool.GetAvailableThreads(worker, io)
      
      Console.WriteLine("Thread pool threads available at startup: ")
      Console.WriteLine("   Worker threads: {0:N0}", worker)
      Console.WriteLine("   Asynchronous I/O threads: {0:N0}", io)
   End Sub
End Module
' The example displays output like the following:
'    Thread pool threads available at startup:
'       Worker threads: 32,767
'       Asynchronous I/O threads: 1,000

Commenti

Quando GetAvailableThreads restituisce, la variabile specificata da workerThreads contiene il numero di thread di lavoro aggiuntivi che possono essere avviati e la variabile specificata completionPortThreads da contiene il numero di thread di I/O asincroni aggiuntivi che possono essere Iniziato.When GetAvailableThreads returns, the variable specified by workerThreads contains the number of additional worker threads that can be started, and the variable specified by completionPortThreads contains the number of additional asynchronous I/O threads that can be started.

Se non sono disponibili thread, le richieste aggiuntive del pool di thread rimangono accodate fino a quando i thread del pool di thread non diventano disponibili.If there are no available threads, additional thread pool requests remain queued until thread pool threads become available.

Si applica a

Vedi anche