예제 #1
0
 public void Cancel()
 {
     if (_operation == null)
     {
         //The request has not been sent yet
         return;
     }
     //_operation can not be assigned to null, so it is safe to use the reference
     _operation.Cancel();
 }
예제 #2
0
 public void OperationState_Cancel_Should_Never_Callback_Client()
 {
     var clientCallbackCounter = 0;
     Action<Exception, Response> clientCallback = (ex, r) =>
     {
         Interlocked.Increment(ref clientCallbackCounter);
     };
     var state = new OperationState(clientCallback);
     state.Cancel();
     state.InvokeCallback(null);
     //Allow callbacks to be called using the default scheduler
     Thread.Sleep(20);
     Assert.AreEqual(0, clientCallbackCounter);
 }
        public void OperationState_Cancel_Should_Never_Callback_Client()
        {
            var clientCallbackCounter = 0;
            Action <Exception, Response> clientCallback = (ex, r) =>
            {
                Interlocked.Increment(ref clientCallbackCounter);
            };
            var state = new OperationState(clientCallback);

            state.Cancel();
            state.InvokeCallback(null);
            //Allow callbacks to be called using the default scheduler
            Thread.Sleep(20);
            Assert.AreEqual(0, clientCallbackCounter);
        }
예제 #4
0
 public void Cancel()
 {
     // if null then the request has not been sent yet
     _operation?.Cancel();
 }