Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FusionCache.CompleteBackgroundFactory => Using "GetAwaiter().GetResult()" instead of ".Result" #258

Merged
merged 10 commits into from
Aug 24, 2024
2 changes: 1 addition & 1 deletion src/ZiggyCreatures.FusionCache/FusionCache.cs
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,7 @@ private void CompleteBackgroundFactory<TValue>(string operationId, string key, F
options.ReThrowBackplaneExceptions = false;

// ADAPTIVE CACHING UPDATE
var lateEntry = FusionCacheMemoryEntry<TValue>.CreateFromOptions(antecedent.Result, options, false, ctx.LastModified, ctx.ETag, null);
var lateEntry = FusionCacheMemoryEntry<TValue>.CreateFromOptions(antecedent.GetAwaiter().GetResult(), options, false, ctx.LastModified, ctx.ETag, null);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Whilst anything is better than .Result, GetAwaiter().GetResult() is still making things synchronous.

Could it not just be awaited?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point, I haven't noticed that! Done.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Whilst anything is better than .Result, GetAwaiter().GetResult() is still making things synchronous.

Could it not just be awaited?

Why? In this case we know for sure the task is already finished, why going through an extra async state machine & friends?


var mca = GetCurrentMemoryAccessor(options);
if (mca is not null)
Expand Down