ConcurrentExclusiveSchedulerPair ConcurrentExclusiveSchedulerPair ConcurrentExclusiveSchedulerPair ConcurrentExclusiveSchedulerPair Class

Definition

Stellt Taskplaner bereit, die auszuführende Aufgaben koordinieren, während sie sicherstellen, dass gleichzeitige Aufgaben gleichzeitig ausgeführt werden können, exklusive Aufgaben zu keinerlei Zeitpunkt.Provides task schedulers that coordinate to execute tasks while ensuring that concurrent tasks may run concurrently and exclusive tasks never do.

public ref class ConcurrentExclusiveSchedulerPair
public class ConcurrentExclusiveSchedulerPair
type ConcurrentExclusiveSchedulerPair = class
Public Class ConcurrentExclusiveSchedulerPair
Vererbung
ConcurrentExclusiveSchedulerPairConcurrentExclusiveSchedulerPairConcurrentExclusiveSchedulerPairConcurrentExclusiveSchedulerPair

Beispiele

Im folgenden Beispiel wird die Verwendung ConcurrentExclusiveSchedulerPair der-Klasse veranschaulicht.The following example shows the use of the ConcurrentExclusiveSchedulerPair class. Leser werden im gleichzeitigen Teil des Schedulers ausgeführt.Readers run on the concurrent part of the scheduler. Der Writer wird auf dem exklusiven Teil des Schedulers ausgeführt.The writer runs on the exclusive part of the scheduler. Dieses Codebeispiel ist Teil eines größeren Beispiels, das für die Vorgehensweise: Geben Sie eine Taskplaner in einem Datenfluss Block -Thema an.This code example is part of a larger example provided for the How to: Specify a Task Scheduler in a Dataflow Block topic.

// 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)

Konstruktoren

ConcurrentExclusiveSchedulerPair() ConcurrentExclusiveSchedulerPair() ConcurrentExclusiveSchedulerPair() ConcurrentExclusiveSchedulerPair()

Initialisiert eine neue Instanz der ConcurrentExclusiveSchedulerPair-Klasse.Initializes a new instance of the ConcurrentExclusiveSchedulerPair class.

ConcurrentExclusiveSchedulerPair(TaskScheduler) ConcurrentExclusiveSchedulerPair(TaskScheduler) ConcurrentExclusiveSchedulerPair(TaskScheduler) ConcurrentExclusiveSchedulerPair(TaskScheduler)

Initialisiert eine neue Instanz der ConcurrentExclusiveSchedulerPair-Klasse, die auf den angegebenen Planer abzielt.Initializes a new instance of the ConcurrentExclusiveSchedulerPair class that targets the specified scheduler.

ConcurrentExclusiveSchedulerPair(TaskScheduler, Int32) ConcurrentExclusiveSchedulerPair(TaskScheduler, Int32) ConcurrentExclusiveSchedulerPair(TaskScheduler, Int32) ConcurrentExclusiveSchedulerPair(TaskScheduler, Int32)

Initialisiert eine neue Instanz der ConcurrentExclusiveSchedulerPair-Klasse für den angegebenen Planer mit einer maximalen Parallelitätsebene.Initializes a new instance of the ConcurrentExclusiveSchedulerPair class that targets the specified scheduler with a maximum concurrency level.

ConcurrentExclusiveSchedulerPair(TaskScheduler, Int32, Int32) ConcurrentExclusiveSchedulerPair(TaskScheduler, Int32, Int32) ConcurrentExclusiveSchedulerPair(TaskScheduler, Int32, Int32) ConcurrentExclusiveSchedulerPair(TaskScheduler, Int32, Int32)

Initialisiert eine neue Instanz der ConcurrentExclusiveSchedulerPair-Klasse für den angegebenen Planer mit einer maximalen Parallelitätsebene und einer maximalen Anzahl von geplanten Aufgaben, die als Einheit verarbeitet werden können.Initializes a new instance of the ConcurrentExclusiveSchedulerPair class that targets the specified scheduler with a maximum concurrency level and a maximum number of scheduled tasks that may be processed as a unit.

Eigenschaften

Completion Completion Completion Completion

Ruft Task ab, der abgeschlossen wird, wenn der Planer die Verarbeitung abgeschlossen hat.Gets a Task that will complete when the scheduler has completed processing.

ConcurrentScheduler ConcurrentScheduler ConcurrentScheduler ConcurrentScheduler

Ruft TaskScheduler ab, das verwendet werden kann, um Aufgaben für dieses Paar zu planen, die gleichzeitig mit anderen Aufgaben für dieses Paar ausgeführt werden können.Gets a TaskScheduler that can be used to schedule tasks to this pair that may run concurrently with other tasks on this pair.

ExclusiveScheduler ExclusiveScheduler ExclusiveScheduler ExclusiveScheduler

Ruft TaskScheduler ab, das verwendet werden kann, um Aufgaben für dieses Paar zu planen, die in Bezug auf andere Aufgaben für dieses Paar exklusiv ausgeführt werden müssen.Gets a TaskScheduler that can be used to schedule tasks to this pair that must run exclusively with regards to other tasks on this pair.

Methoden

Complete() Complete() Complete() Complete()

Informiert das Planerpaar, dass es keine weiteren Aufgaben annehmen sollte.Informs the scheduler pair that it should not accept any more tasks.

Equals(Object) Equals(Object) Equals(Object) Equals(Object)

Bestimmt, ob das angegebene Objekt mit dem aktuellen Objekt identisch ist.Determines whether the specified object is equal to the current object.

(Inherited from Object)
GetHashCode() GetHashCode() GetHashCode() GetHashCode()

Fungiert als Standardhashfunktion.Serves as the default hash function.

(Inherited from Object)
GetType() GetType() GetType() GetType()

Ruft den Type der aktuellen Instanz ab.Gets the Type of the current instance.

(Inherited from Object)
MemberwiseClone() MemberwiseClone() MemberwiseClone() MemberwiseClone()

Erstellt eine flache Kopie des aktuellen Object.Creates a shallow copy of the current Object.

(Inherited from Object)
ToString() ToString() ToString() ToString()

Gibt eine Zeichenfolge zurück, die das aktuelle Objekt darstellt.Returns a string that represents the current object.

(Inherited from Object)

Gilt für: