Ejemplo n.º 1
0
        static void Main()
        {
            Console.WriteLine("Enter timer's name: ");
            string name = Console.ReadLine();

            Console.WriteLine("Enter timer length (in seconds): ");
            int seconds = Convert.ToInt32(Console.ReadLine());

            Console.WriteLine("Enter notification threshold: ");
            int notificationThreshold = Convert.ToInt32(Console.ReadLine());

            Timer timer = new Timer(name, seconds, notificationThreshold);
            //ICountdownNotifier methodsSubscriber = new MethodsSubscriber(timer);
            ICountdownNotifier lambdaSubscriber          = new LambdaSubscriber(timer);
            ICountdownNotifier methodsSubscriber         = new MethodsSubscriber(timer);
            ICountdownNotifier anonymousMethodSubscriber = new AnonymousMethodSubscriber(timer);

            ICountdownNotifier[] countdownNotifiers = new ICountdownNotifier[3];
            countdownNotifiers[0] = methodsSubscriber;
            countdownNotifiers[1] = anonymousMethodSubscriber;
            countdownNotifiers[2] = lambdaSubscriber;

            TimerSubscriberInit(countdownNotifiers);
            TimerSubscriberRun(countdownNotifiers);
            TimerSubscriberEnd(countdownNotifiers);

            timer.StartCountdown();
        }
Ejemplo n.º 2
0
        public IDisposable Subscribe(ISubscriber <R> subscriber)
        {
            var upSubscriber = new LambdaSubscriber <T>(
                onNext: FilterComposer(subscriber),
                onError: subscriber.OnError,
                onComplete: subscriber.OnComplete,
                onSubscribe: (s, c) =>
            {
                subscriber.OnSubscribe(s);
                c();
            },
                onRequest: this.onRequestFilter);

            return(upstream.Subscribe(upSubscriber));
        }