protected override void OnStart(string[] args) { string cwd = Path.GetDirectoryName(Environment.GetCommandLineArgs()[0]); Directory.SetCurrentDirectory(cwd ?? AppDomain.CurrentDomain.BaseDirectory); logService.Log("Starting TradePollerService at" + DateTime.Now); timer = new System.Timers.Timer(); timer.Interval = 1000 * 60 * int.Parse(ConfigurationManager.AppSettings["ScheduleIntervalMinutes"]); timer.Elapsed += new System.Timers.ElapsedEventHandler(OnTimer); TradePollerService.DownloadTrades(powerService, logService); timer.Enabled = true; timer.Start(); }
protected void OnTimer(object sender, System.Timers.ElapsedEventArgs args) { timer.Stop(); TradePollerService.DownloadTrades(powerService, logService); timer.Start(); }