System.Reactive IScheduler “Hello World”

I’ve been reading and hearing lots about RX on blogs and podcasts. It sounds very promising, especially because it is going to utilize the Parallel framework. Unfortunately, I haven’t had much time to play around with it. In the release notes I found this “Remove Observable.Context and replace with IScheduler mechanism.” So I figured IScheduler would be a good place to start snooping around. Over lunch I downloaded the bits and did a quick “hello world” using the static IScheduler. Not very exciting but might help someone get up and running quickly to play around with the very basics.


 static void Main(string[] args)
        {
            var timespan = new TimeSpan(0, 0, 5);

            using (Scheduler.Later.Schedule(DoSomeActionLater, timespan))
            {
                using (Scheduler.Now.Schedule(DoSomeAction))
                {
                    Console.WriteLine("type q to quit");

                    while (Console.ReadLine() != "q")
                    {
                        Thread.Sleep(1000);
                        Console.WriteLine("...");
                    }

                }
            }
        }

        public static void DoSomeActionLater()
        {
            Console.WriteLine("Later");
        }

        public static void DoSomeAction()
        {
            Console.WriteLine("Now");
        }
Disclaimer The information expressed in this blog are my own personal opinions.