Beispiel #1
0
        public void Scheduler_Periodic_HostLifecycleManagement()
        {
            var cur = AppDomain.CurrentDomain.BaseDirectory;

            var domain = AppDomain.CreateDomain("HLN", null, new AppDomainSetup {
                ApplicationBase = cur
            });

            domain.DoCallBack(() =>
            {
                var pep = PlatformEnlightenmentProvider.Current;

                try
                {
                    var hln = new HLN();
                    PlatformEnlightenmentProvider.Current = new PEP(hln);

                    var s = ThreadPoolScheduler.Instance.DisableOptimizations(typeof(ISchedulerPeriodic));

                    var n = 0;
                    var e = new ManualResetEvent(false);

                    var d = Observable.Interval(TimeSpan.FromMilliseconds(100), s).Subscribe(_ =>
                    {
                        if (n++ == 10)
                        {
                            e.Set();
                        }
                    });

                    hln.OnSuspending();
                    hln.OnResuming();

                    Thread.Sleep(250);
                    hln.OnSuspending();

                    Thread.Sleep(150);
                    hln.OnResuming();

                    Thread.Sleep(50);
                    hln.OnSuspending();
                    hln.OnResuming();

                    e.WaitOne();
                    d.Dispose();
                }
                finally
                {
                    PlatformEnlightenmentProvider.Current = pep;
                }
            });
        }
Beispiel #2
0
 public void Reset()
 {
     this._product = new HLN();
 }
Beispiel #3
0
 public PEP(HLN hln)
 {
     _old = PlatformEnlightenmentProvider.Current;
     _hln = hln;
 }