A
A
Akaero2018-03-01 14:26:16
C++ / C#
Akaero, 2018-03-01 14:26:16

How to properly cancel a Task?

I study the cancellation of tasks through
CancellationToken
the button, I hung a handler that cancels the task, and in the task itself I check whether it is canceled with the help token.ThrowIfCancellationRequested();
of. Having reached the throw of an exception, the WF application crashes.
5a97e33a2aba1303339993.png
How to properly handle this exception?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
F
freeExec, 2018-03-01
@Akaero

Once you throw an exception, you must catch it.
See examples or here https://blogs.msdn.microsoft.com/andrewarnottms/20...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question