2012-09-14 5 views
0

나는 Windows phone 7.5 용 flexster 응용 프로그램을 만들고 있습니다. 나는 곧 영화 사진과 영화 ID를 얻고 싶다. 그러나 내 코드가 완료되면 첫 번째 그림 만 목록 이미지에 채워집니다. 난 당신이 이미지 다운로드 보류중인 모든 queue 또는 목록을 유지하지 않는 것을 볼Windows Phone 7 여러 이미지 다운로드

public void NowPlayinJson(string Uri) 
{ 
    string apiUri = string.Format("{0}{1}{2}10", Uri, ApiKay, PagesLimit); 
    WebClient Rclient = new WebClient(); 

    Rclient.DownloadStringAsync(new Uri(apiUri)); 
    Rclient.DownloadStringCompleted += (s, e) => 
    { 
     if (e.Error == null) 
     { 
      jsonStringValue = (e.Result.ToString().Trim()); 
      ImageUri(); 
     } 
    }; 
} 
public void ImageUri() 
{ 
    var ParseImageUri = JObject.Parse(jsonStringValue); 
    var ParseToJson = 
     JsonConvert.DeserializeObject<RootObject(ParseImageUri.ToString()); 

    NowPlayingUri = ParseToJson.movies[0+a].posters.detailed; 

    a++; 
    DownloadImage(); 
} 


public void DownloadImage() 
{ 
    if (!web.IsBusy) 
    { 
     web.OpenReadAsync(new Uri(NowPlayingUri), UriKind.Absolute); 
    } 
    web.OpenReadCompleted += 
     new OpenReadCompletedEventHandler(web_OpenReadCompleted); 
} 

void web_OpenReadCompleted(object sender, OpenReadCompletedEventArgs e) 
{ 
    if (e.Error == null) 
    { 
     while(i<6) 
     { 
      var stream = e.Result; 

      var bi = new BitmapImage(); 
      bi.SetSource(stream); 

      myNowPlayingList.Add(new NowPlaying() 
       { NowImage = bi, NowTitle = "title" + i }); 
      i++; 
      if (b < 6) 
      { 
       b++; 
       ImageUri(); 
      } 
      if(b == 6) 
      { 
       b++; 
       NowPlayingListBox.ItemsSource = myNowPlayingList; 
      } 
     } 
    } 
} 

답변

0

: 이것은 내 코드입니다. webClient can download one Image at a time은 사용 중이면 대기열에 추가합니다. 성공적인 다운로드 큐 길이를 확인하십시오. 비어 있지 않으면 대기열에서 항목을 제거하고 webClient 다운로드에 추가하십시오. maintain a cache 또는 이미지가 캐시 또는 IS에 이미있는 경우 똑같은 것이 더 현명한 것입니다. 다운로드하고 거기서 다른 사람이 이미지를 다운로드 대기열에 추가하면 표시되지 않습니다. 희망이 접근 방식은 당신을 도와줍니다.

+0

답장을 보내 주셔서 감사합니다. 당신이 나 한테 큐의 예를 보여줄 정도로 친절하니? 그렇게 할 수 있다면 크게 감사하겠습니다. – mike

+0

여기를 참조하십시오 [Queue] (http://www.dotnetperls.com/queue). 이 예제에서는 대신 사용자 지정 데이터 형식을 사용하십시오. –