I want to run a processing loop on a separate thread:
_processingThread = new Thread(new ThreadStart(DoWork)));
But DoWork needs to be async:
private async Task QueueProcessorDoWork()
{
while (true)
{
await something();
}
}
How can I connect the two together? When I add async Task
, it doesn't match the parameter of ThreadStart.
It is possible to make the method that sets up the thread async Task
, I think, but I am not sure if that would help.
What's the best solution here? I need my thread to start running then return.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…