private void StopPolling()
{
lock (_stopLock)
{
if (Interlocked.Exchange(ref _running, 0) == 1)
{
_disconnectRegistration.Dispose();
// Complete any ongoing calls to Abort()
// If someone calls Abort() later, have it no-op
AbortHandler.CompleteAbort();
if (_currentRequest != null)
{
// This will no-op if the request is already finished
_currentRequest.Abort();
}
}
}
}