2014-07-18 1 views
2

Windows Phone 8.1 silverlight에서 'Windows.Web.Http.HttpClient'를 사용하여 진행률 표시 줄을 구현하고자했습니다.HttpClient를 사용한 진행 정보

편집 : - 첫 번째 시도 : -

private async Task CheckProgress() 
{ 
    var df = httpClient.GetAsync(new Uri(uriString, UriKind.Absolute)).Progress = Progress; 

    // here i want to stop the execution till whole content downloaded 

    // Reason to wait here 
    // this client download will be used by one more async method. so i need to wait here till the file completely downloaded. 

    // this whole is done in this method only (requirement) 
} 

private void Progress(IAsyncOperationWithProgress<HttpResponseMessage, HttpProgress> asyncInfo, HttpProgress progressInfo) 
{ 
    // here i getting the progress value. 
    // i have already set a call back method that report the progress on the UI. 
} 

한 번 더 시도 : - 그러나 예외 Invocation of delegate at wrong time.

private async Task CheckProgress() 
{ 
    var df = httpClient.GetAsync(new Uri(uriString, UriKind.Absolute)) 

    df.Progress = Progress; 

    await df; 
    // here i want to stop the execution till whole content downloaded 
} 

질문 점점 : -

모두, 나는 01을 멈추고 싶다.전체 다운로드가 완료 될 때까지 대기하는 방법.

누구든지 나를 도와 줄 수 있습니까? 모든 도움이 환호하는 감사합니다 :)

+0

어쩌면 당신은 ManualResetEvent (http://msdn.microsoft.com/en-us/library/system.threading.manualresetevent(v=vs.110))를 볼 수 있습니다. aspx) – Sauleil

+0

언제 어떻게 CheckProgress()를 호출합니까? –

답변

3

나는 내 문제의 해결책을 가지고 있지만 내 조금의 차이는 내 Second Attempt입니다.

private async Task CheckProgress() 
{ 
    var df = httpClient.GetAsync(new Uri(uriString, UriKind.Absolute)) 

    df.Progress = (res, progress) => 
    { 
     // no separate event handler. 
    } 

    await df; 
} 

잘 작동합니다. 누군가가 환호하는 데 도움이되기를 바랍니다 :)

관련 문제