private void DownloadComplete(WebDownload downloadInfo) { Log.Write(Log.Levels.Debug + 1, "GSDR", "Download completed for " + downloadInfo.Url); try { downloadInfo.Verify(); m_quadTile.QuadTileSet.NumberRetries = 0; // Rename temp file to real name File.Delete(m_localFilePath); File.Move(downloadInfo.SavedFilePath, m_localFilePath); // Make the quad tile reload the new image m_quadTile.DownloadRequest = null; m_quadTile.Initialize(); } catch (System.Net.WebException caught) { System.Net.HttpWebResponse response = caught.Response as System.Net.HttpWebResponse; if (response != null && response.StatusCode == System.Net.HttpStatusCode.NotFound) { using (File.Create(m_localFilePath + ".txt")) {} return; } m_quadTile.QuadTileSet.NumberRetries++; } catch { using (File.Create(m_localFilePath + ".txt")) {} if (File.Exists(downloadInfo.SavedFilePath)) { try { File.Delete(downloadInfo.SavedFilePath); } catch (Exception e) { Log.Write(Log.Levels.Error, "GSDR", "could not delete file " + downloadInfo.SavedFilePath + ":"); Log.Write(e); } } } finally { if (download != null) { download.IsComplete = true; } m_quadTile.QuadTileSet.RemoveFromDownloadQueue(this); // potential deadlock! -step // Immediately queue next download m_quadTile.QuadTileSet.ServiceDownloadQueue(); } }
private void DownloadComplete(WebDownload downloadInfo) { try { downloadInfo.Verify(); m_quadTile.QuadTileSet.NumberRetries = 0; // Rename temp file to real name File.Delete(m_localFilePath); File.Move(downloadInfo.SavedFilePath, m_localFilePath); // Make the quad tile reload the new image m_quadTile.DownloadRequest = null; m_quadTile.Initialize(); } catch (WebException caught) { HttpWebResponse response = caught.Response as HttpWebResponse; if (response != null && response.StatusCode == HttpStatusCode.NotFound) { using (File.Create(m_localFilePath + ".txt")) {} return; } m_quadTile.QuadTileSet.NumberRetries++; } catch { using (File.Create(m_localFilePath + ".txt")) {} if (File.Exists(downloadInfo.SavedFilePath)) { File.Delete(downloadInfo.SavedFilePath); } } finally { #region by zzm if (download != null) { download.IsComplete = true; } #endregion m_quadTile.QuadTileSet.RemoveFromDownloadQueue(this); //Immediately queue next download m_quadTile.QuadTileSet.ServiceDownloadQueue(); } }