Home

Rx observable dump should/can be soft-cancelled?

Currently, simple .Dump() for Rx Observable cannot be soft cancelled, I believe this should/can be done with QueryCancellationToken:


So the "Done" should/can be printed when I clicked the "Cancel" button.

Comments

  • Does it work if you replace cancellationToken with QueryCancelToken?
  • @JoeAlbahari sure, I replace the cancellationToken with QueryCancelToken, it works.

    But I just believe it is possible that I don't need to change it to QueryCancelToken :)
  • Unless you explicitly access QueryCancelToken, LINQPad will assume your query is not soft-cancellable.

    A consequence of soft cancellation is that if the query fails to end, you have to click a second time on the Cancel button to kill the process. This is OK when you've accessed QueryCancelToken in your query, because it should be clear what's going on: you've tried to implement soft cancellation, and failed to respond to the token.

    What I want to avoid is a situation where you have to click twice on Cancel without knowing why. In other words, if you've never accessed QueryCancelToken, it would be confusing to have to click twice on Cancel to stop the query.

    In your case, imagine that you add "Thread.Sleep(100000)" to your query, after calling o.OnCompleted. You'd end up having to click Cancel twice, and it wouldn't be obvious why.
Sign In or Register to comment.