, , Cancel() , await / . catch , , TaskCancelationException,
try
{
bool result = await c.MyTask(cts.Token);
return result;
}
catch (Exception exception)
{
Console.WriteLine("catch invoker exception=" + exception.GetType());
Console.WriteLine("catch invoker=" + Thread.CurrentThread.ManagedThreadId);
return true;
}
,
program=10
begin worker=11
begin invoker=11
begin task=11
canceling=10
catch invoker exception=TaskCanceledException
catch invoker=10 <-- parent thread resuming on child cancellation
removing=10
, , - , ( ); , ( c.Abort();), await , ,
program=10
begin worker=11 <
begin invoker=11
begin task=11
Press any key...
end task=12 <
removing=12 <
end invoker=12
end worker=True
end worker=11 <
thread 11, ( Worker), , MyTask, thread 12 ( ), , Invoker, thread 11 , .