Use TaskCache class from Microsoft.Extensions.TaskCache.Sources (#829)

Instead of Task.FromResult(0)
This commit is contained in:
Pavel Krymets 2016-09-07 14:53:06 -07:00 committed by GitHub
parent aa3bcc32df
commit bdbb854bdb
4 changed files with 6 additions and 26 deletions

View File

@ -1,24 +0,0 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System.Threading.Tasks;
namespace Microsoft.AspNetCore.Razor.Internal
{
public static class TaskCache
{
/// <summary>
/// A <see cref="Task"/> that's already completed successfully.
/// </summary>
/// <remarks>
/// We're caching this in a static readonly field to make it more inlinable and avoid the volatile lookup done
/// by <c>Task.CompletedTask</c>.
/// </remarks>
#if NET451
public static readonly Task CompletedTask = Task.FromResult(0);
#else
public static readonly Task CompletedTask = Task.CompletedTask;
#endif
}
}

View File

@ -6,8 +6,8 @@ using System.Collections.Generic;
using System.Diagnostics;
using System.Text.Encodings.Web;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Razor.Internal;
using Microsoft.AspNetCore.Razor.TagHelpers;
using Microsoft.Extensions.Internal;
namespace Microsoft.AspNetCore.Razor.Runtime.TagHelpers
{

View File

@ -2,7 +2,7 @@
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System.Threading.Tasks;
using Microsoft.AspNetCore.Razor.Internal;
using Microsoft.Extensions.Internal;
namespace Microsoft.AspNetCore.Razor.TagHelpers
{

View File

@ -37,6 +37,10 @@
"Microsoft.Extensions.HashCodeCombiner.Sources": {
"type": "build",
"version": "1.1.0-*"
},
"Microsoft.Extensions.TaskCache.Sources": {
"version": "1.1.0-*",
"type": "build"
}
},
"frameworks": {