/// <summary>
        /// Configures the cancellation source.
        /// </summary>
        /// <param name="cancellationToken">The cancellation token to use for cancellation requests.</param>
        protected virtual void ConfigureCancellationSource(CancellationToken cancellationToken)
        {
            cancellationSource?.Dispose();

            cancellationSource = cancellationSourceFactory.Create(cancellationToken);
            if (cancellationSource == null)
            {
                throw new InvalidOperationException("The cancellation source factory did not create a cancellation source.");
            }
        }
Exemplo n.º 2
0
        private void InitializeCancellationSource()
        {
            cancellationSource?.Dispose();

            cancellationSource = cancellationSourceFactory.Create(CancellationToken.None);
            if (cancellationSource == null)
            {
                throw new InvalidOperationException("The cancellation source factory did not produce a cancellation source.");
            }
        }