Ejemplo n.º 1
0
        private static void TestScheduler()
        {
            using var environment = new AppDomainReactiveEnvironment();
            using var platform    = new AppDomainReactivePlatform(environment);

            platform.Configuration.SchedulerType = SchedulerType.Test;

            Initialize(environment, platform);

            var scheduler = (ITestScheduler)platform.QueryEvaluators.First().Scheduler;

            scheduler.ScheduleAbsolute(100, () => { Console.WriteLine("foo"); });
            scheduler.ScheduleAbsolute(150, () => { Console.WriteLine("bar"); });
            scheduler.Start();
        }
Ejemplo n.º 2
0
        private static void SchedulePhysical()
        {
            using var environment = new AppDomainReactiveEnvironment();
            using var platform    = new AppDomainReactivePlatform(environment);

            Initialize(environment, platform);

            var scheduler = platform.QueryEvaluators.First().Scheduler;

            scheduler.Schedule(() => { Console.WriteLine("bar@{0}", DateTimeOffset.Now); });
            scheduler.Schedule(new TimeSpan(0, 0, 5), () => { Console.WriteLine("foo@{0}", DateTimeOffset.Now); });
            var dto = DateTimeOffset.Now + TimeSpan.FromSeconds(10);

            scheduler.Schedule(dto, () => { Console.WriteLine("qux@{0}", DateTimeOffset.Now); });

            Task.Delay(15000).Wait();
        }