/// <summary> /// timer callback. /// This method is called by a timer every 30 seconds to wake up the epg grabber /// the epg grabber will check if its time to grab the epg for a channel /// and ifso it starts the grabbing process /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void _epgTimer_Elapsed(object sender, System.Timers.ElapsedEventArgs e) { //security check, dont allow re-entrancy here if (_reEntrant) { return; } try { _reEntrant = true; //if epg grabber is idle, then grab epg for the next channel if (_state == EpgState.Idle) { return; } else if (_state == EpgState.Grabbing) { //if we are grabbing epg, then check if card is still idle if (_user.CardId >= 0) { if (!IsCardIdle(_user)) { //not idle? then cancel epg grabbing if (_state != EpgState.Idle) { Log.Epg("EpgCard: Canceled epg, card is not idle:{0}", _user.CardId); } _tvController.AbortEPGGrabbing(_user.CardId); _state = EpgState.Idle; _user.CardId = -1; _currentTransponder.InUse = false; return; } } //wait until grabbing has finished TimeSpan ts = DateTime.Now - _grabStartTime; if (ts.TotalMinutes > _epgTimeOut) { //epg grabber timed out. Update database and go back to idle mode Log.Epg("EpgCard: card: {0} timeout after {1} mins", _user.CardId, ts.TotalMinutes); _tvController.AbortEPGGrabbing(_user.CardId); Log.Epg("EpgCard: Aborted epg grab"); } else { Log.Epg("EpgCard: allow grabbing for {0} seconds on card {1}", ts.TotalSeconds, _user.CardId); } } } catch (Exception ex) { Log.Error("EpgCard: Error in EPG timer - {0}", ex.ToString()); } finally { _reEntrant = false; } }