private void ResponseReadyCallback(IAsyncResult ar) { ResponseCallbackInfo info = (ResponseCallbackInfo)ar.AsyncState; firstCall = false; try { var response = info.Request.EndGetResponse(ar); bool goodTile = IsGoodTileResponse(response); if (goodTile) { UpdateStatistics(() => { Statistics.LongValues["DownloadedBytes"] += response.ContentLength; Statistics.IntValues["ImagesLoaded"]++; }); BeginLoadBitmapImpl(response.GetResponseStream(), info.ID); } else { ReportFailure(info.ID); } } catch (WebException exc) { string responseUri = exc.Response != null?exc.Response.ResponseUri.ToString() : "Response=null"; Debug.WriteLine( String.Format( "{0} Network \"{1}\" Failure: url=\"{2}\": {3}", DateTime.Now, Name, responseUri, exc.Message)); ReportFailure(info.ID); } }
private void ResponseReadyCallback(IAsyncResult ar) { ResponseCallbackInfo info = (ResponseCallbackInfo)ar.AsyncState; firstCall = false; try { var response = info.Request.EndGetResponse(ar); bool goodTile = IsGoodTileResponse(response); if (goodTile) { UpdateStatistics(() => { Statistics.LongValues["DownloadedBytes"] += response.ContentLength; Statistics.IntValues["ImagesLoaded"]++; }); // this emulates wrong response from server //byte[] bytes = new byte[] { 0, 1, 2 }; //MemoryStream stream = new MemoryStream(bytes); //BeginLoadBitmapImpl(stream, info.ID); BeginLoadBitmapImpl(response.GetResponseStream(), info.ID); } else { ReportFailure(info.ID); } } catch (WebException exc) { string responseUri = exc.Response != null?exc.Response.ResponseUri.ToString() : "Response=null"; MapsTraceSource.Instance.ServerInformationTraceSource.TraceInformation("{0} Network \"{1}\" Failure: url=\"{2}\": {3}", DateTime.Now, ServerName, responseUri, exc.Message); ReportFailure(info.ID); } }