I simply want to retrieve data asynchronously, and after retrieving the data, show it in the UI (Winforms).
Using .net 4.0, there are 2 ways that I can implement this (I know there are more, but I am using these two):
var task = Task.Factory.StartNew(() => RetrieveData());
task.ContinueWith(x => SetDataInUi(x.Result), TaskScheduler.FromCurrentSynchronizationContext());
OR
var obs = Observable.Start(() => RetrieveData());
obs.ObserveOn(SynchronizationContext.Current).Subscribe(x => SetDataInUi(x));
To the best of my understanding, these will both do the same thing. Is there a reason to choose one over the other?
If you just want to request data from somewhere and print it to screen, I would prefer the first solution.
The second one works too, but RX was designed to help you with data flows. And we all agree it’s not cool to use a complex solution when you can use a simple one 🙂