private void EnterWebBCall(out CancellationToken? cts)
{
lock (_tokenLock)
{
Debug.WriteLine("Starting WebB call...");
// If there is a active REST call, cancel it
// InvalidateToken() is not blocking, so it is possible
// that the next WebB call will be blocked for a while
// in GetResponseAsync() if there are more than two concurrent connections
// to a device, however it shouldn't take long to unblock since the previous
// connections are being aborted.
if (_tokenSource != null)
{
InvalidateToken();
}
_tokenSource = new CancellationTokenSource();
cts = _tokenSource.Token;
}
}