ConcurrentExclusiveSchedulerPair ConcurrentExclusiveSchedulerPair ConcurrentExclusiveSchedulerPair ConcurrentExclusiveSchedulerPair Class

Definizione

Fornisce utilità di pianificazione delle attività coordinate per eseguire attività assicurando al contempo che le attività simultanee possano essere eseguite contemporaneamente a differenza delle attività esclusive.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
Ereditarietà
ConcurrentExclusiveSchedulerPairConcurrentExclusiveSchedulerPairConcurrentExclusiveSchedulerPairConcurrentExclusiveSchedulerPair

Esempi

L'esempio seguente illustra l'uso del ConcurrentExclusiveSchedulerPair classe.The following example shows the use of the ConcurrentExclusiveSchedulerPair class. I lettori eseguito sulla parte simultanea dell'utilità di pianificazione.Readers run on the concurrent part of the scheduler. Esegue il componente scrittura della parte esclusiva dell'utilità di pianificazione.The writer runs on the exclusive part of the scheduler. Questo esempio di codice è parte di un esempio più esaustivo disponibile per il come: Specificare un'utilità di pianificazione in un Dataflow Block argomento.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)

Costruttori

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

Inizializza una nuova istanza della classe ConcurrentExclusiveSchedulerPair.Initializes a new instance of the ConcurrentExclusiveSchedulerPair class.

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

Inizializza una nuova istanza della classe ConcurrentExclusiveSchedulerPair destinata all'utilità di pianificazione specificata.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)

Inizializza una nuova istanza della classe ConcurrentExclusiveSchedulerPair che si rivolge all'utilità di pianificazione specificata con un livello di concorrenza massimo.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)

Inizializza una nuova istanza della classe ConcurrentExclusiveSchedulerPair che si rivolge all'utilità di pianificazione specificata con un livello di concorrenza massimo e un numero massimo di attività pianificate che possono essere elaborate come unità.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.

Proprietà

Completion Completion Completion Completion

Ottiene Task che verrà completato al termine dell'elaborazione da parte dell'utilità di pianificazione.Gets a Task that will complete when the scheduler has completed processing.

ConcurrentScheduler ConcurrentScheduler ConcurrentScheduler ConcurrentScheduler

Ottiene un oggetto TaskScheduler che è possibile utilizzare per pianificare le attività per la coppia eseguibili contemporaneamente ad altre attività sulla coppia.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

Ottiene un oggetto TaskScheduler che è possibile utilizzare per pianificare le attività per la coppia da eseguire esclusivamente in relazione ad altre attività sulla coppia.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.

Metodi

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

Indica alla coppia dell'utilità di pianificazione di non accettare altre attività.Informs the scheduler pair that it should not accept any more tasks.

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

Determina se l'oggetto specificato è uguale all'oggetto corrente.Determines whether the specified object is equal to the current object.

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

Funge da funzione hash predefinita.Serves as the default hash function.

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

Ottiene l'oggetto Type dell'istanza corrente.Gets the Type of the current instance.

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

Crea una copia superficiale dell'oggetto Object corrente.Creates a shallow copy of the current Object.

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

Restituisce una stringa che rappresenta l'oggetto corrente.Returns a string that represents the current object.

(Inherited from Object)

Si applica a