Пример #1
0
        void MainPage_Loaded(object sender, RoutedEventArgs e)
        {
            var portableClass = new PortableClassLibrary.PortableClass();

            // Create timer and route output to list1
            portableClass.CreateTimer(10, TimeSpan.FromSeconds(1.5))
            .Buffer(2)
            .ObserveOnDispatcher()
            .Subscribe(items =>
            {
                foreach (var item in items)
                {
                    list1.Items.Add(item);
                }
            }, onCompleted: () =>
            {
                list1.Items.Add("Finished");
            });

            // Create list observer and route output to list1, but specify scheduler instead of using SubscribeOnDispatcher
            var scheduler = System.Reactive.Concurrency.DispatcherScheduler.Current;

            portableClass.CreateList(scheduler)
            .Delay(TimeSpan.FromSeconds(1))
            .ObserveOn(scheduler)
            .Subscribe(item =>
            {
                list2.Items.Add(item);
            }, onCompleted: () =>
            {
                list2.Items.Add("Finished");
            });
        }
Пример #2
0
        static void Main(string[] args)
        {

            var portableClass = new PortableClassLibrary.PortableClass();

            var scheduler = System.Reactive.Concurrency.CurrentThreadScheduler.Instance;

            // Create timer and route output to console
            portableClass.CreateTimer(10, TimeSpan.FromSeconds(1.5))
                .Buffer(2)
                .ObserveOn(scheduler)
                .Subscribe(items =>
                {
                    Console.WriteLine(" 1: Received items {0}", string.Join(", ", items));
                }, onCompleted: () =>
                {
                    Console.WriteLine(" 1: Finished ");
                });

            // Create list observer and route output to console, but specify scheduler instead of using SubscribeOnDispatcher            
            portableClass.CreateList(scheduler)
                .Delay(TimeSpan.FromSeconds(1))
                .Subscribe(item =>
                {
                    Console.WriteLine(" 2: Received item {0}", item);
                }, onCompleted: () =>
                {
                    Console.WriteLine(" 2: Finished ");
                });

            
            Console.WriteLine("Press enter to exit");
            Console.ReadLine();
        }
Пример #3
0
        void MainPage_Loaded(object sender, RoutedEventArgs e)
        {
            var portableClass = new PortableClassLibrary.PortableClass();

            // Create timer and route output to list1
            portableClass.CreateTimer(10, TimeSpan.FromSeconds(1.5))
                .Buffer(2)
                .ObserveOnDispatcher()
                .Subscribe(items =>
                {
                    foreach (var item in items)
                        list1.Items.Add(item);
                }, onCompleted: () =>
                {
                    list1.Items.Add("Finished");
                });

            // Create list observer and route output to list1, but specify scheduler instead of using SubscribeOnDispatcher
            var scheduler = System.Reactive.Concurrency.DispatcherScheduler.Current;
            portableClass.CreateList(scheduler)
                .Delay(TimeSpan.FromSeconds(1))
                .ObserveOn(scheduler)
                .Subscribe(item =>
                {
                    list2.Items.Add(item);
                }, onCompleted: () =>
                {
                    list2.Items.Add("Finished");
                });


        }
Пример #4
0
        static void Main(string[] args)
        {
            var portableClass = new PortableClassLibrary.PortableClass();

            var scheduler = System.Reactive.Concurrency.CurrentThreadScheduler.Instance;

            // Create timer and route output to console
            portableClass.CreateTimer(10, TimeSpan.FromSeconds(1.5))
            .Buffer(2)
            .ObserveOn(scheduler)
            .Subscribe(items =>
            {
                Console.WriteLine(" 1: Received items {0}", string.Join(", ", items));
            }, onCompleted: () =>
            {
                Console.WriteLine(" 1: Finished ");
            });

            // Create list observer and route output to console, but specify scheduler instead of using SubscribeOnDispatcher
            portableClass.CreateList(scheduler)
            .Delay(TimeSpan.FromSeconds(1))
            .Subscribe(item =>
            {
                Console.WriteLine(" 2: Received item {0}", item);
            }, onCompleted: () =>
            {
                Console.WriteLine(" 2: Finished ");
            });


            Console.WriteLine("Press enter to exit");
            Console.ReadLine();
        }