If I have an async method:
async Task Process()
{
while (condition)
{
await ...;
}
}
And I need to schedule the execution of this method. So I use:
Task.Run(Process);
Do I need to keep the reference of Task
object returned by Task.Run
method in order to ensure that Process
executes to completion?
Here is a bit more context: I need to create a lot of (about 50K) task queues in my application. So I want to create a thread-less queue processing design and which has no cost (apart from memory) when queues are empty (as most of these queues will be).
Gist of the sample class: https://gist.github.com/hemant-jangid/e990b27507596c086e5651f504d0521f