Skip to content
This repository has been archived by the owner on Dec 14, 2018. It is now read-only.

Commit

Permalink
Specify TaskCreationOptions when using TCS
Browse files Browse the repository at this point in the history
Fixes #8558
  • Loading branch information
pranavkm committed Oct 29, 2018
1 parent 0b6932d commit ccde910
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
Expand Up @@ -181,7 +181,7 @@ private Task<CompiledViewDescriptor> OnCacheMiss(string normalizedPath)
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.
Expand Down
Expand Up @@ -88,7 +88,7 @@ public async Task<IHtmlContent> ProcessContentAsync(TagHelperOutput output, Cach
// 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);

Expand Down
2 changes: 1 addition & 1 deletion src/Microsoft.AspNetCore.Mvc.TagHelpers/CacheTagHelper.cs
Expand Up @@ -108,7 +108,7 @@ private async Task<IHtmlContent> CreateCacheEntry(CacheTagKey cacheKey, TagHelpe
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
Expand Down

0 comments on commit ccde910

Please sign in to comment.