System.Threading.Barrier.SignalAndWait C# (CSharp) Method

SignalAndWait() public method

Signals that a participant has reached the Barrier and waits for all other participants to reach the barrier, while observing a .
/// The method was invoked from within a post-phase action, the barrier currently has 0 participants, /// or the barrier is being used by more threads than are registered as participants. /// has been /// canceled. The current instance has already been /// disposed.
public SignalAndWait ( CancellationToken cancellationToken ) : void
cancellationToken CancellationToken The to /// observe.
return void
        public void SignalAndWait(CancellationToken cancellationToken)
        {
            #if DEBUG
            bool result =
            #endif
             SignalAndWait(Timeout.Infinite, cancellationToken);
            #if DEBUG
            Debug.Assert(result);
            #endif
        }

Same methods

Barrier::SignalAndWait ( TimeSpan timeout ) : Boolean
Barrier::SignalAndWait ( TimeSpan timeout, CancellationToken cancellationToken ) : Boolean
Barrier::SignalAndWait ( int millisecondsTimeout ) : bool
Barrier::SignalAndWait ( int millisecondsTimeout, CancellationToken cancellationToken ) : bool
Barrier::SignalAndWait ( ) : void

Usage Example

Example #1
1
        /// <summary>
        /// Download all the images for the current session
        /// </summary>
        public void DownloadAllTreatmentImages()
        {
            Barrier barrier = new Barrier(_patient.PatientTreatment.TrainingList.Count + 2);

            Task treatmentThread = new Task(() =>
            {
                //Downloading all thumbs in treatment
                DownloadTreatment();

                barrier.SignalAndWait();
            });
            treatmentThread.Start();

            foreach(Training t in _patient.PatientTreatment.TrainingList)
            {
                Task tt = new Task(() =>
                {
                    DownloadTraining(_patient.PatientTreatment.TrainingList.IndexOf(t));
                    barrier.SignalAndWait();
                });
                tt.Start();

            }

            barrier.SignalAndWait();
            barrier.Dispose();
        }
All Usage Examples Of System.Threading.Barrier::SignalAndWait