Could my case be solved with async await?

A couple of times recently I’ve had a server (managed, c#) that performs a task that takes a long time. I can’t wait for the task to complete, so I have created a thread that performs the task.

The task is to update another service with a list of objects, one by one.
The main thread of my service just sends the objects to a “to-do” list, and the worker thread will work through the list. If an object is updated from the main thread before the worker thread has handled the object, the old object is replaced by the updated one.
In one case i solved, the worker thread did not loop. Instead, the main thread checked if the worker thread was running, and if not, restarted it.

Could this be solved by using async await somehow? Or is this not what the concept of async await is ment for?

Source: .net

Leave a Reply