Exemplo n.º 1
0
        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;
        }
Exemplo n.º 2
0
        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);
        }
Exemplo n.º 3
0
        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;
        }