Reputation:
I've got some methods that I need to run, one of them should run as a different Thread so I use a Task.Run with lambda, though I want the next method to start just after the Task finishes.
for example I want LastJob()
will start after MoreWork()
is done:
public void DoSomeWork()
{
Task.Run(() => MoreWork());
LastJob();
}
Upvotes: 1
Views: 497
Reputation: 1643
Coy could use the ContinueWith
method, like this:
public void DoSomeWork()
{
var task = Task.Run(() => MoreWork());
task.ContinueWith(() => LastJob()) ;
}
Upvotes: 0