ThreadPool.GetAvailableThreads(Int32, Int32) Methode

Definition

Ruft die Differenz zwischen der von der GetMaxThreads(Int32, Int32)-Methode zurückgegebenen maximalen Anzahl der Threads im Threadpool und der Anzahl der gerade aktiven Threads ab.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)

Parameter

workerThreads
Int32

Die Anzahl der verfügbaren Arbeitsthreads.The number of available worker threads.

completionPortThreads
Int32

Die Anzahl der verfügbaren asynchronen E/A-Threads.The number of available asynchronous I/O threads.

Beispiele

Im folgenden Beispiel wird die Anzahl der Arbeitsthreads und e/a-Threads angezeigt, die verfügbar sind, wenn eine einfache APP gestartet wird.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

Hinweise

Wenn GetAvailableThreads zurückgibt, enthält die durch workerThreads angegebene Variable die Anzahl zusätzlicher Arbeitsthreads, die gestartet werden können, und die durch completionPortThreads angegebene Variable enthält die Anzahl der zusätzlichen asynchronen e/a-Threads, die gestartet werden können.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.

Wenn keine Threads verfügbar sind, verbleiben zusätzliche Thread Pool Anforderungen in der Warteschlange, bis die Threads des Thread Pools verfügbar sind.If there are no available threads, additional thread pool requests remain queued until thread pool threads become available.

Gilt für:

Siehe auch