If I have for example the following code:
Task task = Task.Factory.StartNew(() =>
{
work1();
work2();
work3();
work4();
...
}, token);
if (!task.Wait(10 * 1000))
{
...timeout
}
Is it possible to accomplish a behavior where if I get a timeout the logic inside the time-outed task will get cancelled as well? for example: if work1
took 11 seconds and then finished, I want to make sure all the works afterwards will not be executed.