는 여기 최소의 노력으로 웹 서비스를 효율적으로 비동기 호출을 만들기에 좋은 페이지를 발견 :비동기 콜백 함수가 완료되면 이벤트를 throw합니까?
내가 내가 실행 원하는 코드를 삽입 할 경우 응답이 후에 대한 혼란 스러워요 서버로부터 수신합니까? 이 경우 시스템에서 이벤트를 발생합니까? asyncdownload를 호출 한 후에 코드를 삽입하는 것만으로이 기능을 제공 할 수 없습니다.
나는 분명해야했습니다. 내 프로젝트에이 코드가 있습니다.
private void SearchBarcode(object sender, EventArgs e)
{
WebClient wc = new WebClient();
var o = Observable.FromEvent<DownloadStringCompletedEventArgs>(wc, "DownloadStringCompleted")
// Let's make sure that we’re on the thread pool
.ObserveOn(Scheduler.ThreadPool)
// When the event fires, just select the string and make
// an IObservable<string> instead
.Select(newString => ProcessString(newString.EventArgs.Result))
// Now go back to the UI Thread
.ObserveOn(Scheduler.Dispatcher)
// Subscribe to the observable, and set the label text
.Subscribe(s => parserInput = s);
wc.DownloadStringAsync(new Uri("http://api.search.live.net/xml.aspx?Appid=appidhere&query=barcodenumber&sources=web"));
}
DownloadCompleted 이벤트 호출을 배치 할 수있는 위치가 표시되지 않습니다. SearchBarcode는 이미지의 onclick 핸들러입니다. SearchBarcode가 실행 된 후 컨트롤은 어디로 이동합니까? parserInput의 값을 조작하고 이러한 값을 전달하는 다른 xaml 페이지를 호출하려고합니다. voidCompleted (object sender, DownloadStringCompletedEventArgs e)를 추가하려고 시도했지만 분명히 호출되지 않습니다. 내가 여기서 무엇을 놓치고 있니? :(
정확히 원하는 것을 더 자세히 설명해 주시겠습니까? "DownloadCompleted"이벤트 처리기에 넣은 코드는 다운로드가 완료된 후에 실행됩니다. 그래서 당신이 원하는 것 이상으로? 또는 그 문제는 무엇입니까? –
참조를 위해 이벤트가 발생합니다. 오류가 발생합니다. –
얘들 아, 좀 더 구체적인 질문을 편집했다. 찾아 주셔서 감사합니다 : D – Freakishly