Rx Question: Why Observable.Subscribe(OnNext, OnError, OnCompleted) did not reach to OnError ???

Answered Rx Question: Why Observable.Subscribe(OnNext, OnError, OnCompleted) did not reach to OnError ???

  • 1 august 2012 03:08
     
      Are cod

    I have the following code, but I don't understand why it didn't print out the exception message to the console or it didn't reach to the OnError method. Would you please help!

    Thanks

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Reactive.Linq;
    
    namespace UsingSubcribe
    {
        class Program
        {
            static void Main(string[] args)
            {
                //make an array of numbers 
                var numbers = from number in new int[] { 1, 2, 0, 3 } select 10/number;
                //make an observable sequence out of those numbers
                var observable = numbers.ToObservable();
                //use the ObservableExtention.Subscribe to callbacks
                observable.Subscribe(OnNext, OnError, OnCompleted);
                Console.ReadLine();
            }
            //Call each time a value from the observable sequence is processed
            static void OnNext(int number)
            {
                Console.WriteLine(number);
            }
            //Call if the processing of the observable sequence throw exceptions
            static void OnError(Exception exception)
            {
                Console.WriteLine(@"Oops ""{0}""", exception.Message);
            }
            //Call if all values in the observable sequence have been processed
            static void OnCompleted()
            {
                Console.WriteLine("I'm done!");
            }
        }
    }

    • Mutat de Papy Normand 1 august 2012 17:07 not relared to SQL Server Data Access (From:SQL Server Data Access)
    •  

Toate mesajele