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

Dispose() public method

Releases all resources used by the current instance of Barrier.
Unlike most of the members of Barrier, Dispose is not thread-safe and may not be used concurrently with other members of this instance.
/// The method was invoked from within a post-phase action. ///
public Dispose ( ) : void
return void
        public void Dispose()
        {
            // in case of this is called from the PHA
            if (_actionCallerID != 0 && Environment.CurrentManagedThreadId == _actionCallerID)
            {
                throw new InvalidOperationException(SR.Barrier_InvalidOperation_CalledFromPHA);
            }
            Dispose(true);
            GC.SuppressFinalize(this);
        }

Same methods

Barrier::Dispose ( bool disposing ) : void

Usage Example

Ejemplo n.º 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::Dispose