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

Instead of Task.FromResult(0)
This commit is contained in:
Pavel Krymets 2016-09-07 10:40:13 -07:00 committed by GitHub
parent 22e5dfd8df
commit 18f08fdb2f
7 changed files with 21 additions and 6 deletions

View File

@ -4,6 +4,7 @@
using System;
using System.IO;
using System.Threading.Tasks;
using Microsoft.Extensions.Internal;
namespace Microsoft.AspNetCore.Http
{
@ -16,7 +17,7 @@ namespace Microsoft.AspNetCore.Http
private static readonly Func<object, Task> _disposeDelegate = disposable =>
{
((IDisposable)disposable).Dispose();
return Task.FromResult(0);
return TaskCache.CompletedTask;
};
/// <summary>

View File

@ -24,6 +24,10 @@
"type": "build",
"version": "1.1.0-*"
},
"Microsoft.Extensions.TaskCache.Sources": {
"version": "1.1.0-*",
"type": "build"
},
"System.Text.Encodings.Web": "4.0.0-*"
},
"frameworks": {

View File

@ -4,10 +4,10 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Http.Features;
using Microsoft.AspNetCore.Http.Internal;
using Microsoft.Extensions.Internal;
namespace Microsoft.AspNetCore.Builder.Internal
{
@ -81,7 +81,7 @@ namespace Microsoft.AspNetCore.Builder.Internal
RequestDelegate app = context =>
{
context.Response.StatusCode = 404;
return Task.FromResult(0);
return TaskCache.CompletedTask;
};
foreach (var component in _components.Reverse())

View File

@ -24,6 +24,10 @@
"Microsoft.AspNetCore.WebUtilities": "1.1.0-*",
"Microsoft.Extensions.ObjectPool": "1.1.0-*",
"Microsoft.Extensions.Options": "1.1.0-*",
"Microsoft.Extensions.TaskCache.Sources": {
"version": "1.1.0-*",
"type": "build"
},
"Microsoft.Net.Http.Headers": "1.1.0-*",
"System.Buffers": "4.0.0-*"
},

View File

@ -17,6 +17,7 @@ using System.Threading.Tasks;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Http.Features;
using Microsoft.AspNetCore.Http.Features.Authentication;
using Microsoft.Extensions.Internal;
namespace Microsoft.AspNetCore.Owin
{
@ -67,7 +68,7 @@ namespace Microsoft.AspNetCore.Owin
feature.OnStarting(s =>
{
cb(s);
return Task.FromResult(0);
return TaskCache.CompletedTask;
}, state);
}))
},

View File

@ -7,6 +7,7 @@ using System.Net.WebSockets;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.Extensions.Internal;
namespace Microsoft.AspNetCore.Owin
{
@ -68,7 +69,7 @@ namespace Microsoft.AspNetCore.Owin
else if (messageType == 0x9 || messageType == 0xA)
{
// Ping & Pong, not allowed by the underlying APIs, silently discard.
return Task.FromResult(0);
return TaskCache.CompletedTask;
}
return _webSocket.SendAsync(buffer, OpCodeToEnum(messageType), endOfMessage, cancel);

View File

@ -21,7 +21,11 @@
"xmlDoc": true
},
"dependencies": {
"Microsoft.AspNetCore.Http": "1.1.0-*"
"Microsoft.AspNetCore.Http": "1.1.0-*",
"Microsoft.Extensions.TaskCache.Sources": {
"version": "1.1.0-*",
"type": "build"
}
},
"frameworks": {
"net451": {},