private void _queryRunner_Elapsed(object sender, System.Timers.ElapsedEventArgs e) { if (timerElapsedEventInProgress == false) { timerElapsedEventInProgress = true; timerTriggerCount = 0; try { List <TableCopier> configSettings = MongoDbDal.GetListOfTableCopiers(); foreach (var tab in configSettings) { tab.ImportNextBatch(); } } catch (Exception ex) { Log.Error(ex); } } else { timerTriggerCount++; if (timerTriggerCount >= maxNumberOfRetries) { timerTriggerCount = 0; timerElapsedEventInProgress = false; } } }
protected override void OnStart(string[] args) { try { Log.Info("******Started Running the Query Scheduler*****"); TypeMap = Helper.InitializeTypeHash(); //_queryRunner.Interval = int.Parse(ConfigurationManager.AppSettings["ScheduleInterval"]); _queryRunner.Interval = 5000; _queryRunner.Elapsed += _queryRunner_Elapsed;; MongoDbDal.MongoDB_Initialize(); try { List <TableCopier> configSettings = MongoDbDal.GetListOfTableCopiers(); foreach (var tab in configSettings) { tab.ImportNextBatch(); } } catch (Exception ex) { Log.Error(ex); } _queryRunner.Start(); } catch (Exception ex) { Log.Error(ex); } }