public void Run() { try { SleepState.Stop(true); this.sql = new Sql(true); this.tuner.Open(false); bool flag = false; while (!flag) { Service service = this.epgQueue.Dequeue(this.tuner); if (service == null) { Log.Write(this.tuner.Name + ": このチューナの番組表取得完了。"); break; } int wait = EpgWait.GetInstance().GetWait(service.Nid); Log.Write("{4}: 番組表を取得しています... {1} ({0}/{3}/{2}s)".Formatex(new object[] { this.epgQueue.Count, service.Name, wait, service.EpgBasic ? "基本" : "詳細", this.tuner.Name })); this.tuner.SetService(service); Stopwatch stopwatch = new Stopwatch(); stopwatch.Start(); while (stopwatch.ElapsedMilliseconds < (long)(wait * 1000)) { Record nextRecord = Record.GetNextRecord(this.tuner, this.sql); flag = (this.StoppdApp() || !this.epgQueue.Enable || nextRecord != null); if (flag) { Log.Write(this.tuner.Name + ": 中断しました。" + service.Name); break; } Thread.Sleep(1000); } this.GetEvents(service); } } catch (Exception ex) { Log.Write(this.tuner.Name + ": 番組表取得に失敗しました。" + ex.Message); Log.Write(1, ex.StackTrace); } finally { try { this.sql.Dispose(); this.tuner.Close(); } catch { } SleepState.Stop(false); } }
public void Run() { try { SleepState.Stop(true); this.sql = new Sql(true); this.service = new Service(this.sql, this.record.Fsid); Log.Write(this.tuner.Name + ": 録画を開始します。" + this.record.Title); this.StartRec(); if (this.record.EndTime < DateTime.Now) { throw new Exception("終了時刻が過ぎています。"); } int @int = MainDef.GetInstance().GetInt("record.margin.end"); while (this.record.EndTime - new TimeSpan(0, 0, @int) > DateTime.Now) { if (this.StoppdApp()) { throw new Exception("アプリケーション終了のため、録画を中断します。"); } this.CheckCancel(); this.CheckEvent(); Thread.Sleep(1000); } } catch (Exception ex) { string text = "{0}: 録画に失敗しました。{1}".Formatex(new object[] { this.tuner.Name, ex.Message }); Log.Write(text + " - " + this.record.Title); Log.Write(1, ex.StackTrace); if (this.result != null) { this.result.Code = 1; this.result.Message = text; } } finally { try { this.StopRec(); } catch (Exception ex2) { Log.Write("{0}: 録画終了処理に失敗しました。{1}".Formatex(new object[] { this.tuner.Name, ex2.Message })); Log.Write(1, ex2.StackTrace); } SleepState.Stop(false); this.sql.Dispose(); Log.Write("{0}: 録画終了しました。 - {1}".Formatex(new object[] { this.tuner.Name, this.record.Title })); this.PostProcess(); } }