I have the following test code. I always get the \"Task was cancelled\" error after looping 316934 or 361992 times.
If I am not wrong, there are two possible reasons why
Don't dispose the instance of HttpClient you're using. Weird but fixed for me this problem.