ms-iot/content

while (true) - for Listen() doesn't work for cancelling

Closed this issue · 4 comments

Hello!

First, thank you for this, it has been very helpful. I wanted to point out that the when cancelling the token the while (true) continues to run and lock up the app. I was able to solve it by replacing while (true) with:

while (!ReadCancellationTokenSource.IsCancellationRequested)

Hope that helps!

Richard

Hi Richard,
Are you pointing to a specific sample? Can you give more detail as to the setup of your issue?
Sincere thanks,
IoTGirl

Hello!

My apologies! I am referring to the Listen() function for the following:
https://github.com/ms-iot/content/blob/ba4fd011423e2325b72b6417d6459d9607c8f5af/en-US/Samples/SerialUART.md

Richard

ReadAsync() should through an OperationCanceledException when the cancellation token is canceled. Is an exception not being thrown?

It was throwing that exception, but once I caught the exception I could not escape the loop. I need to be able to disconnect and reconnect multiple times.