public ITaskParticipant CreateParticipant(string tag) { if (_stoppingToken.IsCancellationRequested) throw new OperationCanceledException("The supervisor is stopping, no additional participants can be created"); var id = Interlocked.Increment(ref _nextId); var participant = new TaskParticipant(tag, () => RemoveParticipant(id)); lock (_participants) { _participants.Add(id, participant); } return participant; }
public ITaskParticipant CreateParticipant(string tag) { if (_stoppingToken.IsCancellationRequested) throw new OperationCanceledException("The supervisor is stopping, no additional participants can be created"); long id = Interlocked.Increment(ref _nextId); var participant = new TaskParticipant(tag, () => RemoveParticipant(id)); lock (_participants) { _participants.Add(id, participant); } return participant; }
public ITaskParticipant CreateParticipant(string tag) { if (_stoppingToken.IsCancellationRequested) { throw new OperationCanceledException("The supervisor is stopping, no additional participants can be created"); } var participant = new TaskParticipant(tag); lock (_participants) { _participants.Add(participant); } return(participant); }