β Task tracking
Hi!
I am writing an app that relies on HostedService(s).
I've got a hosted services which has an HttpListener and whenever a new request comes in I use a Channel<T> to dispatch it to another HostedService that consumes this Channel.
This all works great!
Now, inside the
So that in case of a graceful application shutdown I can use the
However, ideally I'd want to clean up this list every once in a while and get rid of all tasks that are completed so that this list stays small.
Throughout the lifetime of the app there could be thousands if not more
Is the clean up even needed from the get go? Is it overkill? Should I even care optimizing this part considering it's only on shutdown anyway?
Thanks in advance!
I hope I provided enough information, if not feel free to ask for more details!
(Please tag me if you reply, so I get a notitication. Thanks
)
I am writing an app that relies on HostedService(s).
I've got a hosted services which has an HttpListener and whenever a new request comes in I use a Channel<T> to dispatch it to another HostedService that consumes this Channel.
This all works great!
Now, inside the
RequestQueueWorker (the consumer of the Channel). I use Task.Run() and add the Task proxy into a list.So that in case of a graceful application shutdown I can use the
StopAsync method of the HostedService to await Task.WhenAll(_runningTasks) to ensure that those tasks are indeed completed.However, ideally I'd want to clean up this list every once in a while and get rid of all tasks that are completed so that this list stays small.
Throughout the lifetime of the app there could be thousands if not more
Task's inside of this list.Is the clean up even needed from the get go? Is it overkill? Should I even care optimizing this part considering it's only on shutdown anyway?
Thanks in advance!
I hope I provided enough information, if not feel free to ask for more details!
(Please tag me if you reply, so I get a notitication. Thanks