Is there a way to accomplish this pseudo-code in C# in .NET4.5?
parallelQueue.attemptDequeueFirstItem(item)
success -> ( doAsyncTask(item).Success(UpdateDatabase) )
-> repeat until dequeue attempt fails
If we don't use a loop, can an item be dequeued from a parallel queue, which if successful results in an action that uses the dequeued item, and then also in another dequeue attempt, and another action, over and over, until the queue is empty?
Action
example withParallel.Invoke
at the end of that code was what exactly what I was looking for! Can such an Action contain anawait
? – TR888 Jan 28 at 10:35Parallel.Invoke
should already be calling the actions asynchronously. TheWriteLine()
at the bottom of that example "awaits" the result (via theinterlocked
) anyway. – Robert Harvey Jan 28 at 15:10