void searchTvDBWorker_DoWork(object sender, DoWorkEventArgs e) { SearchTvDBResults res = new SearchTvDBResults(); res.ErrorMessage = string.Empty; res.TvDBLinks = new List <VM_CrossRef_AniDB_TvDBV2>(); res.ExtraInfo = string.Empty; try { SearchCriteria crit = e.Argument as SearchCriteria; if (!string.IsNullOrEmpty(crit.ExtraInfo)) { res.ExtraInfo = crit.ExtraInfo; } try { List <Azure_CrossRef_AniDB_TvDB> xrefs = VM_ShokoServer.Instance.ShokoServices.GetTVDBCrossRefWebCache(crit.AnimeID, true); if (xrefs != null && xrefs.Count > 0) { foreach (Azure_CrossRef_AniDB_TvDB xref in xrefs) { res.TvDBLinks.Add((VM_CrossRef_AniDB_TvDBV2)xref); } } } catch (Exception ex) { res.ErrorMessage = ex.Message; } e.Result = res; } catch (Exception ex) { res.ErrorMessage = ex.Message; e.Result = res; } }
void searchTvDBWorker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e) { try { SearchTvDBResults res = e.Result as SearchTvDBResults; if (!string.IsNullOrEmpty(res.ErrorMessage)) { //MessageBox.Show() SearchStatus = res.ErrorMessage; return; } foreach (VM_CrossRef_AniDB_TvDBV2 tvxref in res.TvDBLinks) { TVDBResults.Add(tvxref); } SearchStatus = string.Empty; if (!string.IsNullOrEmpty(res.ExtraInfo)) { SearchStatus = res.ExtraInfo; } //SearchStatus = string.Format("{0} Anime still need TvDB approval", link.AnimeNeedingApproval); } catch (Exception ex) { Utils.ShowErrorMessage(ex); } finally { Cursor = Cursors.Arrow; btnRandomAnime.IsEnabled = true; btnSearch.IsEnabled = true; } }