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

[FEATURE] Expose currently backgrounded factory tasks on DI scope #368

Open
Fube opened this issue Jan 28, 2025 · 0 comments
Open

[FEATURE] Expose currently backgrounded factory tasks on DI scope #368

Fube opened this issue Jan 28, 2025 · 0 comments

Comments

@Fube
Copy link

Fube commented Jan 28, 2025

Problem

Backgrounded factories are invisible.
If your (now backgrounded) factory depends on something in the DI scope, you have no way of preventing the scope from being disposed.
This can lead your factory to fail.

Solution

When backgrounding a task in MaybeBackgroundCompleteTimedOutFactory, would it not be possible to alert something like "hey this task is now running in the background, heads up!".

This would then allow you to prevent the scope from being disposed by doing await fusionCache.WaitForBackgroundedTasks() or something of the sort.

I see a Activities.EventNames.FactoryBackgroundMove event is fired, maybe we can create & add a FusionCacheEventsHub.BackgroundFactoryMove next to it?

Alternatives

None come to mind.

Additional context

I use FusionCache on a web server and I am fine with leaving the scope open for the backgrounded tasks once an HTTP response has been issued.
I imagine putting something in HttpContext.Response.OnCompleted to await the background factories.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant