我正在使用这段代码片段来进行带有取消令牌的异步查询:
var _client = new HttpClient( /* some setthngs */ );
_client.GetAsync(someUrl, cancellationToken).ContinueWith(gettingTask => {
cancellationToken.ThrowIfCancellationRequested();
SomeStuffToDO();
}, TaskScheduler.FromCurrentSynchronizationContext());
}, TaskScheduler.FromCurrentSynchronizationContext());
然而,当操作被取消时,cancellationToken.ThrowIfCancellationRequested();
会抛出一个异常。我知道这行代码应该执行这件事。但是,在开发环境中,异常会导致Visual Studio停止工作。我该如何避免这种情况?