80 references to CancellationToken
dotnet-svcutil-lib (1)
FrameworkFork\System.ServiceModel\Internals\System\Runtime\TimeoutHelper.cs (1)
15private static readonly CancellationToken s_precancelledToken = new CancellationToken(true);
InMemory.FunctionalTests (1)
Http2\Http2StreamTests.cs (1)
3796await Assert.ThrowsAsync<OperationCanceledException>(() => context.Response.WriteAsync("hello,", new CancellationToken(true)));
Microsoft.AspNetCore.Components (1)
RenderTree\Renderer.cs (1)
30internal static readonly Task CanceledRenderTask = Task.FromCanceled(new CancellationToken(canceled: true));
Microsoft.AspNetCore.Components.Server (1)
Circuits\RemoteRenderer.cs (1)
21private static readonly Task CanceledTask = Task.FromCanceled(new CancellationToken(canceled: true));
Microsoft.AspNetCore.Http.Connections.Tests (1)
LongPollingTests.cs (1)
49var timeoutToken = new CancellationToken(true);
Microsoft.AspNetCore.Http.Extensions.Tests (6)
HttpResponseJsonExtensionsTests.cs (2)
384context.RequestAborted = new CancellationToken(canceled: true); 418context.RequestAborted = new CancellationToken(canceled: true);
SendFileResponseExtensionsTests.cs (4)
56() => response.SendFileAsync("testfile1kb.txt", 1, 3, new CancellationToken(canceled: true))); 70() => response.SendFileAsync("testfile1kb.txt", 1, 3, new CancellationToken(canceled: true))); 78context.RequestAborted = new CancellationToken(canceled: true); 93var token = new CancellationToken(canceled: true);
Microsoft.AspNetCore.RateLimiting.Tests (1)
RateLimitingMiddlewareTests.cs (1)
149context.RequestAborted = new CancellationToken(true);
Microsoft.AspNetCore.Server.HttpSys (1)
RequestProcessing\RequestContext.cs (1)
172_disconnectToken = new CancellationToken(canceled: true);
Microsoft.AspNetCore.Server.IIS (1)
Core\IISHttpContext.IHttpRequestLifetimeFeature.cs (1)
30return new CancellationToken(true);
Microsoft.AspNetCore.Server.Kestrel.Core (3)
Internal\Http\HttpProtocol.cs (2)
290return new CancellationToken(false); 295return new CancellationToken(true);
Internal\KestrelServerImpl.cs (1)
287StopAsync(new CancellationToken(canceled: true)).GetAwaiter().GetResult();
Microsoft.AspNetCore.Server.Kestrel.Core.Tests (4)
AddressBinderTests.cs (1)
268AddressBinder.BindAsync(options.GetListenOptions(), addressBindContext, _noopUseHttps, new CancellationToken(true)));
ConnectionDispatcherTests.cs (3)
34connection.ConnectionClosed = new CancellationToken(canceled: true); 78connection.ConnectionClosed = new CancellationToken(canceled: true); 99connection.ConnectionClosed = new CancellationToken(canceled: true);
Microsoft.AspNetCore.SignalR.Client.Tests (6)
HttpConnectionTests.ConnectionLifecycle.cs (1)
473await Assert.ThrowsAsync<TaskCanceledException>(async () => await connection.StartAsync(new CancellationToken(canceled: true))).DefaultTimeout();
HubConnectionTests.ConnectionLifecycle.cs (1)
543await Assert.ThrowsAsync<TaskCanceledException>(() => hubConnection.StartAsync(new CancellationToken(canceled: true))).DefaultTimeout();
HubConnectionTests.cs (4)
192hubConnection.InvokeAsync<int>("testMethod", cancellationToken: new CancellationToken(canceled: true)).DefaultTimeout()); 211hubConnection.SendAsync("testMethod", cancellationToken: new CancellationToken(canceled: true)).DefaultTimeout()); 253hubConnection.StreamAsChannelAsync<int>("testMethod", cancellationToken: new CancellationToken(canceled: true)).DefaultTimeout()); 271var result = hubConnection.StreamAsync<int>("testMethod", cancellationToken: new CancellationToken(canceled: true));
Microsoft.AspNetCore.StaticFiles.Tests (1)
StaticFileContextTest.cs (1)
130httpContext.RequestAborted = new CancellationToken(canceled: true);
Microsoft.AspNetCore.WebUtilities.Tests (2)
HttpResponseStreamWriterTest.cs (2)
385var cancellationToken = new CancellationToken(true); 441var cancellationToken = new CancellationToken(true);
Microsoft.CodeAnalysis (6)
DiagnosticAnalyzer\AnalyzerDriver.cs (4)
448_lazyInitializeTask = Task.FromCanceled(new CancellationToken(canceled: true)); 451_lazyPrimaryTask = Task.FromCanceled(new CancellationToken(canceled: true)); 650_lazyPrimaryTask ??= Task.FromCanceled(new CancellationToken(canceled: true)); 684_lazyPrimaryTask = Task.FromCanceled(new CancellationToken(canceled: true));
DiagnosticAnalyzer\AsyncQueue.cs (2)
240: Task.FromCanceled<TElement>(new CancellationToken(canceled: true)); 249new CancellationToken(canceled: true).ThrowIfCancellationRequested();
Microsoft.CodeAnalysis.CSharp.Semantic.UnitTests (2)
SourceGeneration\GeneratorDriverTests.cs (2)
1713Assert.Throws<OperationCanceledException>(() => timeoutFunc(30, new CancellationToken(true))); 1714Assert.Throws<OperationCanceledException>(() => userTimeoutFunc(30, new CancellationToken(true)));
Microsoft.CodeAnalysis.Workspaces.UnitTests (20)
FindAllDeclarationsTests.cs (7)
119var declarations = await SymbolFinder.FindDeclarationsAsync(project, "Test", true, SymbolFilter.All, new CancellationToken(true)); 279var declarations = await SymbolFinder.FindSourceDeclarationsAsync(project, "Test", true, SymbolFilter.All, new CancellationToken(true)); 378var declarations = await SymbolFinder.FindSourceDeclarationsAsync(solution, "Test", true, SymbolFilter.All, new CancellationToken(true)); 439var declarations = await SymbolFinder.FindSourceDeclarationsAsync(project, str => str.Contains("Test"), SymbolFilter.All, new CancellationToken(true)); 500await SymbolFinder.FindSourceDeclarationsAsync(solution, str => str.Contains("Test"), SymbolFilter.All, new CancellationToken(true)); 558var declarations = await SymbolFinder.FindSourceDeclarationsWithPatternAsync(project, "test", SymbolFilter.All, new CancellationToken(true)); 616await SymbolFinder.FindSourceDeclarationsWithPatternAsync(solution, "test", SymbolFilter.All, new CancellationToken(true));
UtilityTest\SpecializedTasksTests.cs (11)
55var whenAll = SpecializedTasks.WhenAll([new ValueTask<int>(Task.FromCanceled<int>(new CancellationToken(true)))]); 79var cancellationToken = new CancellationToken(canceled: false); 93var cancellationToken = new CancellationToken(canceled: false); 136var cancellationToken = new CancellationToken(canceled: false); 242var cancellationToken = new CancellationToken(canceled: false); 269var cancellationToken = new CancellationToken(canceled: false); 368var cancellationToken = new CancellationToken(canceled: false); 390var cancellationToken = new CancellationToken(canceled: false); 412var cancellationToken = new CancellationToken(canceled: false); 527var cancellationToken = new CancellationToken(canceled: false); 548var cancellationToken = new CancellationToken(canceled: false);
UtilityTest\TaskExtensionsTests.cs (2)
20Assert.Throws<TaskCanceledException>(() => Task.FromCanceled<int>(new CancellationToken(canceled: true)).WaitAndGetResult_CanCallOnBackground(CancellationToken.None)); 21Assert.Throws<OperationCanceledException>(() => new TaskCompletionSource<int>().Task.WaitAndGetResult_CanCallOnBackground(new CancellationToken(canceled: true)));
Microsoft.Extensions.AI.Abstractions.Tests (2)
Image\ImageGeneratorExtensionsTests.cs (2)
68var cancellationToken = new CancellationToken(canceled: false); 114var cancellationToken = new CancellationToken(canceled: false);
Microsoft.Extensions.Http.Diagnostics.Tests (3)
Logging\HttpRequestBodyReaderTest.cs (1)
111var token = new CancellationToken(true);
Logging\HttpResponseBodyReaderTest.cs (2)
134var token = new CancellationToken(true); 242var token = new CancellationToken(true);
Microsoft.Extensions.Http.Resilience.Tests (1)
Polly\HttpRetryStrategyOptionsTests.cs (1)
29[new OperationCanceledExceptionMock(new TimeoutException()), new CancellationToken(canceled: true), false],
Microsoft.Gen.Logging.Unit.Tests (1)
ParserTests.cs (1)
601", cancellationToken: new CancellationToken(true)));
Microsoft.Gen.Metrics.Unit.Tests (1)
ParserTests.cs (1)
560cancellationToken: new CancellationToken(true)));
Microsoft.Gen.MetricsReports.Unit.Tests (1)
EmitterTests.cs (1)
87emitter.GenerateReport(_metricClasses, new CancellationToken(true));
Microsoft.VisualStudio.LanguageServices.Implementation (1)
SolutionExplorer\SourceGeneratedFileItems\SourceGeneratedFileItemSource.cs (1)
191_cancellationSeries.CreateNext(new CancellationToken(canceled: true));
System.Data.Common (1)
System\Data\Common\AdapterUtil.Common.cs (1)
22internal static Task<T> CreatedTaskWithCancellation<T>() => Task.FromCanceled<T>(new CancellationToken(true));
System.Linq.Parallel (1)
System\Linq\Parallel\Scheduling\CancellationState.cs (1)
39return new CancellationToken(false);
System.Net.WebSockets (1)
System\Net\WebSockets\WebSocketStream.cs (1)
260ct = new CancellationToken(canceled: true);
System.Private.CoreLib (6)
src\libraries\System.Private.CoreLib\src\System\Threading\Tasks\TaskExtensions.cs (2)
22Task.FromCanceled(new CancellationToken(true)); 38Task.FromCanceled<TResult>(new CancellationToken(true));
src\libraries\System.Private.CoreLib\src\System\Threading\Tasks\ValueTask.cs (4)
219return s_canceledTask ??= Task.FromCanceled(new CancellationToken(canceled: true)); 271vtst.TrySetCanceled(new CancellationToken(true)); 627return s_canceledTask ??= Task.FromCanceled<TResult>(new CancellationToken(true)); 678vtst.TrySetCanceled(new CancellationToken(true));
System.ServiceModel.Federation (1)
System\Runtime\TimeoutHelper.cs (1)
12private static readonly CancellationToken s_precancelledToken = new CancellationToken(true);
System.ServiceModel.Primitives (1)
Internals\System\Runtime\TimeoutHelper.cs (1)
16private static readonly CancellationToken s_precancelledToken = new CancellationToken(true);
System.Threading.Channels (1)
System\Threading\Channels\ChannelUtilities.cs (1)
63error is OperationCanceledException oce ? Task.FromCanceled<T>(oce.CancellationToken.IsCancellationRequested ? oce.CancellationToken : new CancellationToken(true)) :