コード例 #1
0
        protected override void OnStart(string[] args)
        {
            mainThread = new Task(() =>
            {
                try
                {
                    Thread.Sleep(20 * 1000);
                    PollingController pollingController = new PollingController();
                    DateTime nextPollTime = DateTime.Now;
                    while (!isCancelled)
                    {
                        if (nextPollTime <= DateTime.Now)
                        {
                            pollingController.PollAllPollersOnce();
                            nextPollTime = DateTime.Now.AddMinutes(5);
                        }

                        Thread.Sleep(100);
                    }
                }
                catch (Exception ex)
                {
                    this.EventLog.WriteEntry(ex.ToString(), EventLogEntryType.Error);
                }
            });

            mainThread.Start();
        }
コード例 #2
0
        public void TestPoll()
        {
            var db = new UptimeDB();

            var originalValueCount = db.PollCategoryValue.Count();

            var poller = new PollingController(db, (ex) =>
            {
                Assert.Fail(ex.ToString());
            });
            poller.PollAllPollersOnce();

            var db2 = new UptimeDB();
            var resultCount = db2.PollCategoryValue.Count();
            if (resultCount <= originalValueCount)
                Assert.Fail("Only found {0} values in the database and there were originally {1} so there wasn't enough of an increase after polling.", resultCount, originalValueCount);
        }
コード例 #3
0
 /// <summary>
 /// The main entry point for the application.
 /// </summary>
 static void Main(string[] args)
 {
     if (args.Any(a=>a == "Console"))
     {
         var p = new PollingController();
         p.PollAllPollersOnce();
     }
     else
     {
         ServiceBase[] ServicesToRun;
         ServicesToRun = new ServiceBase[]
                             {
                                 new Service1()
                             };
         ServiceBase.Run(ServicesToRun);
     }
 }