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 as well, using a T:System.TimeSpan to measure the time interval.
is a negative number /// other than -1 milliseconds, which represents an infinite time-out, or it is greater than /// . /// 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. /// The current instance has already been /// disposed.
public SignalAndWait ( TimeSpan timeout ) : Boolean
timeout TimeSpan A that represents the number of /// milliseconds to wait, or a that represents -1 milliseconds to /// wait indefinitely.
return Boolean
        public Boolean SignalAndWait(TimeSpan timeout)
        {
            return SignalAndWait(timeout, new CancellationToken());
        }

Same methods

Barrier::SignalAndWait ( TimeSpan timeout, CancellationToken cancellationToken ) : Boolean
Barrier::SignalAndWait ( int millisecondsTimeout ) : bool
Barrier::SignalAndWait ( int millisecondsTimeout, CancellationToken cancellationToken ) : bool
Barrier::SignalAndWait ( ) : void
Barrier::SignalAndWait ( CancellationToken cancellationToken ) : 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