private void startServiceEpgMenuItem_Click(object sender, EventArgs e) { try { int id = this.services[this.serviceView.FocusedItem.Index].Id; Service service = new Service(this.sql, id); RecTimer.GetInstance().StartEpg(service); } catch (Exception ex) { Log.Write("番組表取得開始に失敗しました。[詳細] " + ex.Message); Log.Write(1, ex.StackTrace); } }
private void Tick(object sender, EventArgs e) { if (SleepState.IsStop()) { return; } EpgQueue epgQueue = RecTimer.GetInstance().GetEpgQueue(); if (epgQueue.Enable && epgQueue.Count > 0) { return; } if (this.GetNextTime() - DateTime.Now > new TimeSpan(0, 10, 0)) { this.Sleep(); } }
private DateTime GetNextTime() { DateTime nextEpgTime = RecTimer.GetInstance().NextEpgTime; long nextRecordTime = this.GetNextRecordTime(); DateTime dateTime; if (nextRecordTime == -1L) { dateTime = new DateTime(9999, 1, 1); } else { dateTime = new DateTime(nextRecordTime); } if (!(dateTime < nextEpgTime)) { return(nextEpgTime); } return(dateTime); }
//一番早い有効な予約、または番組表取得の時間を取得 DateTime GetNextTime() { //次の番組表取得 var epg = RecTimer.GetInstance().NextEpgTime; DateTime rec; //次の予約 long tick = GetNextRecordTime(); if (tick == -1) { rec = new DateTime(9999, 1, 1); } else { rec = new DateTime(tick); } //早い方を返す return(rec < epg ? rec : epg); }
static void Main(string[] args) { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); WebServer ws = null; var ticket = new Ticket("/tvmaid/mutex/main"); try { if (ticket.GetOwner(60 * 1000) == false) { ticket = null; throw new AppException("時間内に二重起動が解消されませんでした。"); } Log.Write(AppVer); LoadDef(); //先に読み込んでおく GenreConv.GetInstance(); TextConv.GetInstance(); if (args.Length == 1 && args[0] == "-tunerupdate") { UpdateTuner(); } TaskList.StartNew(() => { RecTimer.GetInstance().Start(); }); ws = new WebServer(); TaskList.StartNew(() => { ws.Start(); }); TunerMon.GetInstance(); Application.Run(new Tasktray()); } catch (Exception e) { MessageBox.Show("このエラーは回復できないため、アプリケーションは終了します。[詳細]" + e.Message, Logo); } finally { if (ws != null) { ws.Dispose(); } RecTimer.GetInstance().Dispose(); if (StateDef != null) { StateDef.Save(); } //スレッド終了待ち int i = 0; while (TaskList.GetInstance().IsFinish() == false) { System.Threading.Thread.Sleep(100); i++; if (i > 300) { break; } } if (ticket != null) { ticket.Dispose(); } } }
private void startEpgMenuItem_Click(object sender, EventArgs e) { RecTimer.GetInstance().StartEpg(); }
private bool StoppdApp() { return(RecTimer.GetInstance().Stopped()); }
private static void Main(string[] args) { List <Task> tasks = new List <Task>(); WebServer ws = null; // mark10als // Log.Write(AppData.AppName + " " + AppData.AppVersion); Log.Write(AppData.AppName + " " + AppData.AppVersion + " " + AppData.AppMod); Ticket ticket = new Ticket("/tvmaid/mutex/main"); try { if (!ticket.GetOwner(10000)) { ticket = null; throw new Exception("時間内に二重起動が解消されませんでした。"); } Program.LoadDef(); if (MainDef.GetInstance()["debug"] == "1") { Log.GetInstance().SetLevel(1); Log.Write("debug mode 1 に設定しました。"); } Program.CopyPlugin(); if (args.Length == 1 && args[0] == "-tunerupdate") { Program.UpdateTuner(); } Task item = Task.Factory.StartNew(() => { RecTimer.GetInstance().Run(); }, TaskCreationOptions.AttachedToParent); tasks.Add(item); ws = new WebServer(); item = Task.Factory.StartNew(() => { ws.Start(); }, TaskCreationOptions.AttachedToParent); tasks.Add(item); Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new TunerMon()); } catch (Exception ex) { string str = ex.Message + ex.StackTrace; MessageBox.Show("このエラーは回復できないため、アプリケーションは終了します。[詳細]" + str, AppData.AppName); } finally { if (ws != null) { ws.Dispose(); } RecTimer.GetInstance().Dispose(); ExitForm form = new ExitForm(30); Task.Factory.StartNew(delegate { Task.WaitAll(tasks.ToArray(), 30000); }).ContinueWith(delegate(Task _) { form.Close(); }, TaskScheduler.FromCurrentSynchronizationContext()); form.ShowDialog(); if (ticket != null) { ticket.Dispose(); } Program.StartNextProcess(); } }