private static void HandleGetResponseResult(IAsyncResult result) { var pendingResponse = result; PriorityQueue.AddWorkItem(() => { var responseState = (ResponseState)pendingResponse.AsyncState; try { var response = responseState.WebRequest.EndGetResponse(pendingResponse); byte[] bytes = null; using (var stream = response.GetResponseStream()) { bytes = new byte[stream.Length]; stream.Read(bytes, 0, (int)stream.Length); } var pc = new PendingCompletion(responseState.Image, responseState.Uri, new MemoryStream(bytes)); PriorityQueue.AddStorageWorkItem(() => _iso.Write(responseState.Uri, bytes)); PriorityQueue.AddUiWorkItem(() => HandleCompletion(pc)); //System.Diagnostics.Debug.WriteLine("Saving to the iso image cache..."); } catch (WebException) { // Ignore web exceptions (ex: not found) } catch { // Other exceptions... } }); }