ConcurrentExclusiveSchedulerPair 클래스

정의

동시 작업을 동시에 실행하고 전용 작업은 실행하지 않으면서 작업을 실행하도록 조정하는 작업 스케줄러를 제공합니다.

public ref class ConcurrentExclusiveSchedulerPair
public class ConcurrentExclusiveSchedulerPair
type ConcurrentExclusiveSchedulerPair = class
Public Class ConcurrentExclusiveSchedulerPair
상속
ConcurrentExclusiveSchedulerPair

예제

다음 예제에서는 사용 된 ConcurrentExclusiveSchedulerPair 클래스입니다. 판독기는 스케줄러의 부분을 동시에 실행합니다. 스케줄러의 전용 부분에 작성기를 실행합니다. 이 코드 예제는 방법: 데이터 흐름 블록 아티클에서 작업 스케줄러 지정에 제공된 더 큰 예제의 일부입니다.

// Create a ConcurrentExclusiveSchedulerPair object.
// Readers will run on the concurrent part of the scheduler pair.
// The writer will run on the exclusive part of the scheduler pair.
var taskSchedulerPair = new ConcurrentExclusiveSchedulerPair();

// Create an ActionBlock<int> object for each reader CheckBox object.
// Each ActionBlock<int> object represents an action that can read 
// from a resource in parallel to other readers.
// Specifying the concurrent part of the scheduler pair enables the 
// reader to run in parallel to other actions that are managed by 
// that scheduler.
var readerActions =
   from checkBox in new CheckBox[] { checkBox1, checkBox2, checkBox3 }
   select new ActionBlock<int>(milliseconds =>
   {
       // Toggle the check box to the checked state.
       toggleCheckBox.Post(checkBox);

       // Perform the read action. For demonstration, suspend the current
       // thread to simulate a lengthy read operation.
       Thread.Sleep(milliseconds);

       // Toggle the check box to the unchecked state.
       toggleCheckBox.Post(checkBox);
   },
   new ExecutionDataflowBlockOptions
   {
       TaskScheduler = taskSchedulerPair.ConcurrentScheduler
   });

// Create an ActionBlock<int> object for the writer CheckBox object.
// This ActionBlock<int> object represents an action that writes to 
// a resource, but cannot run in parallel to readers.
// Specifying the exclusive part of the scheduler pair enables the 
// writer to run in exclusively with respect to other actions that are 
// managed by the scheduler pair.
var writerAction = new ActionBlock<int>(milliseconds =>
{
    // Toggle the check box to the checked state.
    toggleCheckBox.Post(checkBox4);

    // Perform the write action. For demonstration, suspend the current
    // thread to simulate a lengthy write operation.
    Thread.Sleep(milliseconds);

    // Toggle the check box to the unchecked state.
    toggleCheckBox.Post(checkBox4);
},
new ExecutionDataflowBlockOptions
{
    TaskScheduler = taskSchedulerPair.ExclusiveScheduler
});

// Link the broadcaster to each reader and writer block.
// The BroadcastBlock<T> class propagates values that it 
// receives to all connected targets.
foreach (var readerAction in readerActions)
{
    broadcaster.LinkTo(readerAction);
}
broadcaster.LinkTo(writerAction);
' Create a ConcurrentExclusiveSchedulerPair object.
' Readers will run on the concurrent part of the scheduler pair.
' The writer will run on the exclusive part of the scheduler pair.
Dim taskSchedulerPair = New ConcurrentExclusiveSchedulerPair()

' Create an ActionBlock<int> object for each reader CheckBox object.
' Each ActionBlock<int> object represents an action that can read 
' from a resource in parallel to other readers.
' Specifying the concurrent part of the scheduler pair enables the 
' reader to run in parallel to other actions that are managed by 
' that scheduler.
Dim readerActions = From checkBox In New CheckBox() {checkBox1, checkBox2, checkBox3}
                    Select New ActionBlock(Of Integer)(Sub(milliseconds)
                                                           ' Toggle the check box to the checked state.
                                                           ' Perform the read action. For demonstration, suspend the current
                                                           ' thread to simulate a lengthy read operation.
                                                           ' Toggle the check box to the unchecked state.
                                                           toggleCheckBox.Post(checkBox)
                                                           Thread.Sleep(milliseconds)
                                                           toggleCheckBox.Post(checkBox)
                                                       End Sub, New ExecutionDataflowBlockOptions With {.TaskScheduler = taskSchedulerPair.ConcurrentScheduler})

' Create an ActionBlock<int> object for the writer CheckBox object.
' This ActionBlock<int> object represents an action that writes to 
' a resource, but cannot run in parallel to readers.
' Specifying the exclusive part of the scheduler pair enables the 
' writer to run in exclusively with respect to other actions that are 
' managed by the scheduler pair.
Dim writerAction = New ActionBlock(Of Integer)(Sub(milliseconds)
                                                   ' Toggle the check box to the checked state.
                                                   ' Perform the write action. For demonstration, suspend the current
                                                   ' thread to simulate a lengthy write operation.
                                                   ' Toggle the check box to the unchecked state.
                                                   toggleCheckBox.Post(checkBox4)
                                                   Thread.Sleep(milliseconds)
                                                   toggleCheckBox.Post(checkBox4)
                                               End Sub, New ExecutionDataflowBlockOptions With {.TaskScheduler = taskSchedulerPair.ExclusiveScheduler})

' Link the broadcaster to each reader and writer block.
' The BroadcastBlock<T> class propagates values that it 
' receives to all connected targets.
For Each readerAction In readerActions
    broadcaster.LinkTo(readerAction)
Next readerAction
broadcaster.LinkTo(writerAction)

생성자

ConcurrentExclusiveSchedulerPair()

ConcurrentExclusiveSchedulerPair 클래스의 새 인스턴스를 초기화합니다.

ConcurrentExclusiveSchedulerPair(TaskScheduler)

지정된 스케줄러를 대상으로 하는 ConcurrentExclusiveSchedulerPair 클래스의 새 인스턴스를 초기화합니다.

ConcurrentExclusiveSchedulerPair(TaskScheduler, Int32)

최대 동시성 수준을 사용하여 지정된 스케줄러를 대상으로 하는 ConcurrentExclusiveSchedulerPair 클래스의 새 인스턴스를 초기화합니다.

ConcurrentExclusiveSchedulerPair(TaskScheduler, Int32, Int32)

최대 동시성 수준과 예약된 최대 작업 수(단위로 처리될 수도 있음)와 함께 지정한 스케줄러를 대상으로 하는 ConcurrentExclusiveSchedulerPair 클래스의 새 인스턴스를 초기화하고 보호 수준에 서명합니다.

속성

Completion

스케줄러가 처리를 완료하면 완료될 Task를 가져옵니다.

ConcurrentScheduler

이 쌍에서 다른 작업과 동시에 실행될 수 있는 이 쌍에 대한 작업을 예약하는 데 사용할 수 있는 TaskScheduler를 가져옵니다.

ExclusiveScheduler

이 쌍에서 다른 작업과 관련하여 단독으로 실행되어야 하는 이 쌍에 대한 작업을 예약하는 데 사용할 수 있는 TaskScheduler를 가져옵니다.

메서드

Complete()

스케줄러 쌍에게 추가 작업을 수락할 수 없음을 알립니다.

Equals(Object)

지정된 개체가 현재 개체와 같은지 확인합니다.

(다음에서 상속됨 Object)
GetHashCode()

기본 해시 함수로 작동합니다.

(다음에서 상속됨 Object)
GetType()

현재 인스턴스의 Type을 가져옵니다.

(다음에서 상속됨 Object)
MemberwiseClone()

현재 Object의 단순 복사본을 만듭니다.

(다음에서 상속됨 Object)
ToString()

현재 개체를 나타내는 문자열을 반환합니다.

(다음에서 상속됨 Object)

적용 대상