Use a valid canceled task (#11161)

This commit is contained in:
Pranav K 2019-06-14 13:13:53 -07:00 committed by GitHub
parent 87106707d6
commit cd7eda9a33
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 3 deletions

View File

@ -3,13 +3,11 @@
using System; using System;
using System.Collections.Concurrent; using System.Collections.Concurrent;
using System.Collections.Generic;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using System.Text.Encodings.Web; using System.Text.Encodings.Web;
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using MessagePack;
using Microsoft.AspNetCore.Components.Rendering; using Microsoft.AspNetCore.Components.Rendering;
using Microsoft.AspNetCore.Components.Server.Circuits; using Microsoft.AspNetCore.Components.Server.Circuits;
using Microsoft.AspNetCore.SignalR; using Microsoft.AspNetCore.SignalR;
@ -20,6 +18,8 @@ namespace Microsoft.AspNetCore.Components.Browser.Rendering
{ {
internal class RemoteRenderer : HtmlRenderer internal class RemoteRenderer : HtmlRenderer
{ {
private static readonly Task CanceledTask = Task.FromCanceled(new CancellationToken(canceled: true));
private readonly IJSRuntime _jsRuntime; private readonly IJSRuntime _jsRuntime;
private readonly CircuitClientProxy _client; private readonly CircuitClientProxy _client;
private readonly RendererRegistry _rendererRegistry; private readonly RendererRegistry _rendererRegistry;
@ -114,7 +114,7 @@ namespace Microsoft.AspNetCore.Components.Browser.Rendering
if (_disposing) if (_disposing)
{ {
// We are being disposed, so do no work. // We are being disposed, so do no work.
return Task.FromCanceled<object>(CancellationToken.None); return CanceledTask;
} }
// Note that we have to capture the data as a byte[] synchronously here, because // Note that we have to capture the data as a byte[] synchronously here, because