if (asyncRequest != null && asyncRequest.CancellationToken.IsCancellationRequested)
{
// Cancel async operation, before I/O starts.
- asyncRequest.CompleteUserWithError(new TaskCanceledException());
+ asyncRequest.CompleteUserWithError(new OperationCanceledException(asyncRequest.CancellationToken));
return;
}
{
if (asyncRequest != null && asyncRequest.CancellationToken.IsCancellationRequested)
{
- // Return async operation if cancellation requested.
- asyncRequest.CompleteUserWithError(new TaskCanceledException());
+ // Cancel async operation if cancellation requested.
+ asyncRequest.CompleteUserWithError(new OperationCanceledException(asyncRequest.CancellationToken));
return;
}
{
if (asyncRequest != null && asyncRequest.CancellationToken.IsCancellationRequested)
{
- // Return async operation if cancellation requested.
- asyncRequest.CompleteUserWithError(new TaskCanceledException());
+ // Cancel async operation if cancellation requested.
+ asyncRequest.CompleteUserWithError(new OperationCanceledException(asyncRequest.CancellationToken));
return;
}
{
if (asyncRequest != null && asyncRequest.CancellationToken.IsCancellationRequested)
{
- asyncRequest.CompleteUserWithError(new TaskCanceledException());
+ asyncRequest.CompleteUserWithError(new OperationCanceledException(asyncRequest.CancellationToken));
return;
}
{
if (asyncRequest != null && asyncRequest.CancellationToken.IsCancellationRequested)
{
- asyncRequest.CompleteUserWithError(new TaskCanceledException());
+ asyncRequest.CompleteUserWithError(new OperationCanceledException(asyncRequest.CancellationToken));
return;
}
{
if (asyncRequest != null && asyncRequest.CancellationToken.IsCancellationRequested)
{
- asyncRequest.CompleteUserWithError(new TaskCanceledException());
+ asyncRequest.CompleteUserWithError(new OperationCanceledException(asyncRequest.CancellationToken));
return;
}
serverOptions.RemoteCertificateValidationCallback = AllowAnyServerCertificate;
CancellationTokenSource cts = new CancellationTokenSource();
- Task clientTask = Assert.ThrowsAsync<TaskCanceledException>(() => client.AuthenticateAsClientAsync(clientOptions, cts.Token));
+ Task clientTask = Assert.ThrowsAnyAsync<OperationCanceledException>(() => client.AuthenticateAsClientAsync(clientOptions, cts.Token));
Task serverTask = Assert.ThrowsAsync<TimeoutException>(() => server.AuthenticateAsServerAsync(serverOptions, CancellationToken.None));
cts.Cancel();
CancellationTokenSource cts = new CancellationTokenSource();
Task clientTask = Assert.ThrowsAsync<TimeoutException>(() => client.AuthenticateAsClientAsync(clientOptions, CancellationToken.None));
- Task serverTask = Assert.ThrowsAsync<TaskCanceledException>(() => server.AuthenticateAsServerAsync(serverOptions, cts.Token));
+ Task serverTask = Assert.ThrowsAnyAsync<OperationCanceledException>(() => server.AuthenticateAsServerAsync(serverOptions, cts.Token));
cts.Cancel();
Assert.True(Task.WaitAll(new[] { clientTask, serverTask }, TestConfiguration.PassingTestTimeoutMilliseconds));