cpprestsdk icon indicating copy to clipboard operation
cpprestsdk copied to clipboard

pplx task cancellation on linux

Open slepasteur opened this issue 10 years ago • 2 comments

I tried to execute the cancelling parallel tasks exemple on linux but it didn't work (the task was never canceled).

Here is the output: Creating task... Performing work... Performing work... Performing work... Performing work... Canceling task... Waiting for task to complete... Performing work... Performing work... Performing work... Performing work... Performing work... ...

slepasteur avatar Jun 01 '16 09:06 slepasteur

This sounds like a bug. I'll mark it for investigation.

ras0219-msft avatar Jun 16 '16 22:06 ras0219-msft

This is a known issue with pplx when not interoperating with the MS concurrency libraries (i.e., if CPPREST_FORCE_PPLX is defined). The call to is_task_cancellation_requested() always returns false (and is documented as such in the code).

The workaround is to instead capture the cancellation token into your lambda expression, and check token.is_canceled() to decide whether or not to cancel the task.

mmthomas avatar Sep 05 '16 17:09 mmthomas