다음을 통해 공유


Scheduler.ThreadPool 속성

ThreadPool에서 작업을 예약하는 스케줄러를 가져옵니다.

네임스페이스:System.Reactive.Concurrency
어셈블리: System.Reactive(System.Reactive.dll)

Syntax

'Declaration
Public Shared ReadOnly Property ThreadPool As ThreadPoolScheduler
    Get
'Usage
Dim value As ThreadPoolScheduler

value = Scheduler.ThreadPool
public static ThreadPoolScheduler ThreadPool { get; }
public:
static property ThreadPoolScheduler^ ThreadPool {
    ThreadPoolScheduler^ get ();
}
static member ThreadPool : ThreadPoolScheduler
static function get ThreadPool () : ThreadPoolScheduler

속성 값

형식: System.Reactive.Concurrency.ThreadPoolScheduler
스레드 풀 스케줄러입니다.

설명

ThreadPool 스케줄러는 .NET 스레드 풀에서 실행될 작업을 예약합니다. 이 스케줄러는 짧은 실행 작업에 적합합니다.

예제

이 코드 예제에서는 Generate 연산자를 사용하여 1000보다 작은 완벽한 정수 시퀀스를 생성합니다. generate 연산자와 연결된 처리는 ThreadPool 스케줄러를 사용하여 .NET 스레드 풀에서 실행되도록 예약됩니다.

using System;
using System.Reactive.Linq;
using System.Reactive.Concurrency;

namespace Example
{
  class Program
  {
    static void Main()
    {
      //*********************************************************************************************//
      //*** Generate a sequence of integers which are the perfect squares that are less than 100  ***//
      //*********************************************************************************************//

      var obs = Observable.Generate(1,                      // Initial state value
                                    x => x * x < 1000,      // The termination condition. Terminate generation when false (the integer squared is not less than 1000)
                                    x => ++x,               // Iteration step function updates the state and returns the new state. In this case state is incremented by 1 
                                    x => x * x,             // Selector function determines the next resulting value in the sequence. The state of type in is squared.
                                    Scheduler.ThreadPool);  // The ThreadPool scheduler runs the generation on a thread pool thread instead of the main thread.

      using (IDisposable handle = obs.Subscribe(x => Console.WriteLine(x)))
      {
        Console.WriteLine("Press ENTER to exit...\n");
        Console.ReadLine();
      }
    }
  }
}

다음 출력에서는 예제 코드를 실행하는 방법을 보여 줍니다.

Press ENTER to exit...

1
4
9
16
25
36
49
64
81
100
121
144
169
196
225
256
289
324
361
400
441
484
529
576
625
676
729
784
841
900
961

참고 항목

참조

Scheduler 클래스

System.Reactive.Concurrency 네임스페이스