The Author Online Book Forums are Moving

The Author Online Book Forums will soon redirect to Manning's liveBook and liveVideo. All book forum content will migrate to liveBook's discussion forum and all video forum content will migrate to liveVideo. Log in to liveBook or liveVideo with your Manning credentials to join the discussion!

Thank you for your engagement in the AoF over the years! We look forward to offering you a more enhanced forum experience.

For point no 3 "If multiple calls have gone to server due to less polling time. How to take response with latest request and skip older request data". How will the switch operator help?

Following is the code attached in which I need to print only numbers in increasing order. Means latest response that is generated from asyncCall sequence should be considered and any order request made to asyncCall should be ignored in all cases. How can I achieve that?


      private static void GenerateObservableSequence()
        {
            var timerData = Observable.Timer(TimeSpan.Zero,
                TimeSpan.FromSeconds(1));

            var asyncCall = Observable.FromAsync<int>(() =>
            {
                TaskCompletionSource<int> t = new TaskCompletionSource<int>();
                i++;

                int k = i;
                var rndNo = new Random().Next(3, 10);
                Task.Delay(TimeSpan.FromSeconds(rndNo)).ContinueWith(r => { t.SetResult(k); });
                return t.Task;
            });

            var obs = from t in timerData
            from data in asyncCall
            select data;

            var hot = obs.Publish();
            hot.Connect();
                
                hot.Subscribe(j => 
            {
                Console.WriteLine("{0}", j);
            });
        }
Under 5.3 section you have mentioned a interesting case study of periodically pulling data from a web service to show latest information. This kind of cases are mostly seen as Push mechanism is not implemented always from server end. Can you please elaborate on this case study with following points:
1. Start and stop polling based on internet connection
2. How to handle error without breaking Observable pipeline flow. As web services tend to throw many kinds of error
3. If multiple calls have gone to server due to less polling time. How to take response with latest request and skip older request data
4. How to synchronize observers subscription over multiple data pushed in Observable pipeline in parallel

Also if possible please incorporate some other case studies like these. This will help us to understand and think more from implementation point in day to day programming.

Till now this book has been great source of learning material for Rx. Eagerly waiting for upcoming chapters.