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

AddParticipant() public method

Notifies the Barrier that there will be an additional participant.
/// Adding a participant would cause the barrier's participant count to /// exceed . /// /// The method was invoked from within a post-phase action. /// The current instance has already been /// disposed.
public AddParticipant ( ) : long
return long
        public long AddParticipant()
        {
            try
            {
                return AddParticipants(1);
            }
            catch (ArgumentOutOfRangeException)
            {
                throw new InvalidOperationException(SR.Barrier_AddParticipants_Overflow_ArgumentOutOfRange);
            }
        }

Usage Example

        public BarrierLimitedModeCharacterCounter(ITextFile textFile, Barrier barrier)
        {
            this.barrier = barrier;
            barrier.AddParticipant();

            charCounts = new Lazy<IReadOnlyDictionary<char, int>>(() => BufferAndCount(textFile));
        }
All Usage Examples Of System.Threading.Barrier::AddParticipant