/// <summary> /// Agent that runs a scheduled task /// </summary> /// <param name="task"> /// The invoked task /// </param> /// <remarks> /// This method is called when a periodic or resource intensive task is invoked /// </remarks> protected override void OnInvoke(ScheduledTask task) { if (!_mangaDB.DatabaseExists()) { // The database is expected to be there, if it's not then simply abort scheduled task and any future execution. Abort(); return; } // Download latest chapters WebClient client = new WebClient(); client.DownloadStringCompleted += new DownloadStringCompletedEventHandler(OnLatestChaptersTransferCompleted); client.DownloadStringAsync(new Uri(ServerConstants._serverUri + string.Format(Constants._latestRequestTemplate, ServerConstants._apiKey))); _waitHandle.WaitOne(TimeSpan.FromMinutes(9)); NotifyComplete(); }
public AppData() { this.LatestChapters = new ObservableCollection <MangaAbstractModel>(); this.Series = new SeriesByName(new List <SeriesModel>()); this.ChaptersInSeries = new ObservableCollection <MangaAbstractModel>(); this._currentlyViewingSeries = null; this._currentlyViewingChapter = null; this._currentlyViewingPage = -1; this._downloadAllContext = 0; this._downloadAllProgress = new Dictionary <uint, uint>(); this._downloadPageContext = 0; this._downloadPageProgress = new Dictionary <uint, uint>(); _backgroundTransfer = new BackgroundTransfer(); _mangaDB = new MangaDataContext(Constants._DBConnectionString); if (!_mangaDB.DatabaseExists()) { _mangaDB.CreateDatabase(); } }