using System;
using System.Collections.Generic;
using System.Linq;
using System.Reactive;
using System.Reactive.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;

namespace Timing
{
    class Example47
    {
        public static void UseTimestamp()
        {
            // Listing 11-47
            // Zmodyfikowany by można było zrezygnować z subskrypcji
            IObservable<Timestamped<long>> src =
                Observable.Interval(TimeSpan.FromSeconds(1)).Timestamp();
            IDisposable sub = src.Subscribe(i => Console.WriteLine("Zdarzenie {0} o godzinie {1:T}",
                                                 i.Value, i.Timestamp.ToLocalTime()));


            Thread.Sleep(5000);
            sub.Dispose();
        }
    }
}
