Specify TaskCreationOptions when using TCS

Fixes https://github.com/aspnet/Mvc/issues/8558
This commit is contained in:
Pranav K 2018-10-26 11:18:33 -07:00
parent 0b6932dc15
commit ccde910b29
3 changed files with 3 additions and 3 deletions

View File

@ -181,7 +181,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Internal
cacheEntryOptions.ExpirationTokens.Add(item.ExpirationTokens[i]);
}
taskSource = new TaskCompletionSource<CompiledViewDescriptor>();
taskSource = new TaskCompletionSource<CompiledViewDescriptor>(creationOptions: TaskCreationOptions.RunContinuationsAsynchronously);
if (item.SupportsCompilation)
{
// We'll compile in just a sec, be patient.

View File

@ -88,7 +88,7 @@ namespace Microsoft.AspNetCore.Mvc.TagHelpers.Cache
// There is a small race condition here between TryGetValue and TryAdd that might cause the
// content to be computed more than once. We don't care about this race as the probability of
// happening is very small and the impact is not critical.
var tcs = new TaskCompletionSource<IHtmlContent>();
var tcs = new TaskCompletionSource<IHtmlContent>(creationOptions: TaskCreationOptions.RunContinuationsAsynchronously);
_workers.TryAdd(key, tcs.Task);

View File

@ -108,7 +108,7 @@ namespace Microsoft.AspNetCore.Mvc.TagHelpers
var options = GetMemoryCacheEntryOptions();
options.AddExpirationToken(new CancellationChangeToken(tokenSource.Token));
options.SetSize(PlaceholderSize);
var tcs = new TaskCompletionSource<IHtmlContent>();
var tcs = new TaskCompletionSource<IHtmlContent>(creationOptions: TaskCreationOptions.RunContinuationsAsynchronously);
// The returned value is ignored, we only do this so that
// the compiler doesn't complain about the returned task