Skip to content

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

Closed
@Fube

Description

@Fube

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions