var sub = observable.Subscribe(data => my_action(data));
When I dispose the sub
variable it will unsubscribe. Ok, but when doing so will it wait for my_action
to end if it was already called?
Update 1: I ask for conscious decision, not some side-effects. Compare this to Threading.Timer -- in order to wait for action you have to call special Dispose
method.
Update 2: I ask for waiting for action to end, not to cancel the action.
It depends. If the action and the dispose occur on the same thread, then the disposal will happen after the action completes. If the action runs on a different thread to the disposal then they occur independently and it is possible for the disposal to occur while action is executing.