Ejemplo n.º 1
0
        public static void Main(string[] args)
        {
            // We recommend to run multiple instances of the example.

            var processId = Process.GetCurrentProcess().Id;

            Console.Title = string.Format("Process ID: {0}", processId);

            using (var conn = ConnectionMultiplexer.Connect("localhost:6379"))
                using (var scheduler = new Scheduler <Request>(SchedulerCallback, new ObservableRedisQueue <Request>(conn, "test", 0)))
                {
                    scheduler.Error          += Scheduler_Error;
                    scheduler.SchedulerError += Scheduler_SchedulerError;

                    for (int i = 0; i < 10000; i++)
                    {
                        scheduler.AddAndRun(new Request()
                        {
                            ProcessId      = processId,
                            Timestamp      = Stopwatch.GetTimestamp(),
                            SequenceNumber = i,
                        });
                    }

                    Console.WriteLine("Pressy any key to exit.");
                    Console.ReadKey(true);
                }
        }
Ejemplo n.º 2
0
        public static void Main(string[] args)
        {
            using (var scheduler = new Scheduler <MyItem>(SchedulerCallback))
            {
                scheduler.Error          += Scheduler_Error;
                scheduler.SchedulerError += Scheduler_SchedulerError;

                Parallel.Invoke(Enumerable.Repeat <Action>(() =>
                {
                    for (int i = 0; i < 10; i++)
                    {
                        scheduler.AddAndRun(new MyItem(Thread.CurrentThread.ManagedThreadId));
                    }
                }, 10).ToArray());

                Console.WriteLine("Pressy any key to cancel.");
                Console.ReadKey(true);

                scheduler.Stop();

                Console.WriteLine("Pressy any key to exit.");
                Console.ReadKey(true);
            }
        }