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(); }
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); }
public void Cancel() { // if null then the request has not been sent yet _operation?.Cancel(); }