0
WebClient를 사용하여 POST 요청을 보내려고하고 있으며 UI가 멈추는 것을 막기 위해 "UploadStringAsync"를 사용하고 있습니다. 나는 업로드가 완료된 후 변수를 반환 할,하지만 난 오류가 점점 오전 :uploadstring의 변수를 반환했습니다.
try
{
List<string> results = new List<string>();
//Contact the API
using (WebClient getResults = new WebClient())
{
...
//Send the POST and get the result!
getResults.UploadStringCompleted += (sender, e) =>
{
dynamic finalResult = JObject.Parse(e.Result);//finalResults.selectedProfile.name
results.Add(finalResult.selectedProfile.name);
return (results.toArray()); //Error is here
};
getResults.UploadStringAsync(new Uri(URL), "POST", postInfo);
}
//This is what was there before: return (results.ToArray());
}
catch (Exception ex)
{
...
}
I 나타나는 오류는 다음과 같습니다 당신이 어떤 비동기 구조를 사용하려는 경우
Since 'System.Net.UploadStringCompletedEventHandler' returns void, a return keyword must not be followed by an object expression
배열을 매개 변수로 사용하고 처리기 끝에서 호출하는 함수를 작성하지 않는 이유는 무엇입니까? – Brutus