public ITaskScope CreateScope(string tag) { if (_stoppingToken.IsCancellationRequested) throw new OperationCanceledException("The supervisor is stopping, no additional scopes can be created"); var id = Interlocked.Increment(ref _nextId); var scope = new TaskScope(tag, () => RemoveParticipant(id)); lock (_participants) { _participants.Add(id, scope); } return scope; }
public ITaskScope CreateScope(string tag) { if (_stoppingToken.IsCancellationRequested) { throw new OperationCanceledException("The supervisor is stopping, no additional scopes can be created"); } var scope = new TaskScope(tag); lock (_participants) { _participants.Add(scope); } return(scope); }