Implementing IObserver

Processes the information

class Program
{
    static async Task Main(string[] args)
    {
        IObservable<int> observable = Observable.Create<int>(obs =>
        {
            return Task.Run(() =>
            {
                for (int i = 0; i < 10; i++)
                {
                    obs.OnNext(i);
                    Thread.Sleep(250);
                }
            });
        });

        observable.Subscribe(new Obs<int>());

        await new TaskCompletionSource<object>().Task;
    }

    class Obs<T> : IObserver<T>
    {
        // Called for each item in the observable
        public void OnNext(T value)
        {
            Console.WriteLine("Value is: " + value);
        }
        
        // Called when there are no more items left in the loop
        public void OnCompleted()
        {
            Console.WriteLine("Finished");
        }

        // Called when everything goes wrong
        public void OnError(Exception error)
        {
            Console.WriteLine("Stopped working");
        }
    }
}