Reputation: 3424
Reactive Extensions has these three methods:
ToTask
: Returns a task that will receive the last value or the exception produced by the observable sequence.LastAsync
: Returns the last element of an observable sequenceRunAsync
: Gets an awaiter that returns the last value of the observable sequence or throws an exception if the sequence is empty.They sound very similar. How would I choose which one to use?
Upvotes: 4
Views: 870
Reputation: 13182
You should choose based on what you want to do with returning value, as these methods have different return types with different capabilities. If you only want to await
last result you can use any of the methods above as they provide same behavior in this case. They all handle empty observable collections and exceptions when awaited.
Upvotes: 1