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)

생성자

Name Description
ConcurrentExclusiveSchedulerPair()

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

ConcurrentExclusiveSchedulerPair(TaskScheduler, Int32, Int32)

최대 동시성 수준 및 단위로 처리될 수 있는 예약된 작업의 최대 수를 사용하여 지정된 스케줄러를 대상으로 하는 클래스의 새 인스턴스 ConcurrentExclusiveSchedulerPair 를 초기화합니다.

ConcurrentExclusiveSchedulerPair(TaskScheduler, Int32)

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

ConcurrentExclusiveSchedulerPair(TaskScheduler)

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

속성

Name Description
Completion

스케줄러가 Task 처리를 완료할 때 완료되는 값을 가져옵니다.

ConcurrentScheduler

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

ExclusiveScheduler

이 쌍의 TaskScheduler 다른 작업과 관련하여 단독으로 실행해야 하는 이 쌍으로 작업을 예약하는 데 사용할 수 있는 A를 가져옵니다.

메서드

Name Description
Complete()

스케줄러 쌍에 더 이상 작업을 수락해서는 안 되도록 알릴 수 있습니다.

Equals(Object)

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

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

기본 해시 함수로 사용됩니다.

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

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

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

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

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

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

(다음에서 상속됨 Object)

적용 대상