I want to refactor some code that starts a new thread to use async await The code execute long running tasks in a queue. It was in Framework 4 and I am moving up to 4.5.2
Here is the old code
public void Spawn(object data)
{
var pts = new ParameterizedThreadStart(DoWork);
new Thread(pts).Start(data);
}
public void DoWork()
{
// things to run in new thread
}
How do I make DoWork run in a new thread?
I have tried the following
public async Task DoWork()
{
// things to run in new thread
}
However I can't figure out how to call it inside Spawn. If I try
await DoWork()
then intellisense wants me to make Spawn() Async so this is starting to look like a big refactor. Am I on the right path?