TimeSpan UpdateSource(Repo repo, Source newest) { newest.LastUpdateTime = DateTime.UtcNow; newest.ExpirationTime = newest.LastUpdateTime + newest.GetExpirationDuration(); repo.Update(newest); try { Console.WriteLine("U: Updating {0} {1}", newest.GetType().Name, newest.GetDistinguisher()); newest.Update(repo, InformUpdate); LastUpdateTime = DateTime.UtcNow; InformUpdate(newest); return(TimeSpan.FromSeconds(2)); } catch (Exception ex) { Console.WriteLine("U: Fail: {0}: {1}", ex.GetType().Name, ex); var webex = ex as WebException; if (webex != null && webex.Response != null && ((HttpWebResponse)webex.Response).StatusCode == HttpStatusCode.NotFound) { return(TimeSpan.FromSeconds(2)); } else { return(TimeSpan.FromSeconds(30)); } } }