private void ThreadedLoad() { try { item.LoadDetails(); ThreadAssist.ProxyToMain(delegate { ClearMessages(); if (item.Details != null) { gui.Contents.UpdateDetails(); } }); } catch (Exception e) { Log.Error("Error loading IA item details", e); ThreadAssist.ProxyToMain(delegate { var web_e = e as System.Net.WebException; if (web_e != null && web_e.Status == System.Net.WebExceptionStatus.Timeout) { SetStatus(Catalog.GetString("Timed out getting item details from the Internet Archive"), true); CurrentMessage.AddAction(new MessageAction(Catalog.GetString("Try Again"), (o, a) => Load())); } else { SetStatus(Catalog.GetString("Error getting item details from the Internet Archive"), true); } }); } }
private void ThreadedFetch(int page) { bool success = false; total_results = 0; status_text = ""; Exception err = null; int old_page = search.Page; search.Page = page; ThreadAssist.ProxyToMain(delegate { SetStatus(Catalog.GetString("Searching the Internet Archive"), false, true, "gtk-find"); }); IA.SearchResults results = null; try { results = search.GetResults(); total_results = results.TotalResults; } catch (System.Net.WebException e) { Log.Error("Error searching the Internet Archive", e); results = null; err = e; } if (results != null) { try { foreach (var result in results) { model.Add(result); // HACK to remove ugly empty description //if (track.Comment == "There is currently no description for this item.") //track.Comment = null; } success = true; } catch (Exception e) { err = e; Log.Error("Error searching the Internet Archive", e); } } if (success) { int count = model.Count; if (total_results == 0) { ThreadAssist.ProxyToMain(delegate { SetStatus(Catalog.GetString("No matches."), false, false, "gtk-info"); }); } else { ThreadAssist.ProxyToMain(ClearMessages); status_text = String.Format(Catalog.GetPluralString( "Showing 1 match", "Showing 1 to {0:N0} of {1:N0} total matches", total_results), count, total_results ); } } else { search.Page = old_page; ThreadAssist.ProxyToMain(delegate { var web_e = err as System.Net.WebException; if (web_e != null && web_e.Status == System.Net.WebExceptionStatus.Timeout) { SetStatus(Catalog.GetString("Timed out searching the Internet Archive"), true); CurrentMessage.AddAction(new MessageAction(Catalog.GetString("Try Again"), (o, a) => { if (page == 0) { Reload(); } else { FetchMore(); } })); } else { SetStatus(Catalog.GetString("Error searching the Internet Archive"), true); } }); } ThreadAssist.ProxyToMain(delegate { model.Reload(); OnUpdated(); }); }