Xamarin Studio에서 Android 응용 프로그램을 만들고 있지만 OnPostExecute()
이 실행되지 않습니다.AsyncTask (C#)에서 OnPostExecute가 실행되지 않았습니다.
protected override Java.Lang.Object DoInBackground(params Java.Lang.Object[] native_parms) {
System.IO.Stream ins = null;
try {
URL url = new URL(this.url);
HttpURLConnection conn = (HttpURLConnection) url.OpenConnection();
conn.ReadTimeout = 10000;
conn.ConnectTimeout = 15000;
conn.RequestMethod = "GET";
conn.DoInput = true;
conn.DoOutput = true;
Dictionary<string, string> queryParams = new Dictionary<string, string>();
queryParams.Add("username", this.username);
queryParams.Add("password", this.password);
System.IO.Stream os = conn.OutputStream;
BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(os, "UTF-8"));
// getQueryString() just builds a query string
writer.Write(getQueryString(queryParams));
writer.Flush();
writer.Close();
os.Close();
// Starts the query
conn.Connect();
int response = (int) conn.ResponseCode;
System.Console.WriteLine(response);
ins = conn.InputStream;
// Convert the InputStream into a string
String contentAsString = read(ins, conn.ContentLength);
System.Console.WriteLine("Done the task.");
return contentAsString;
// Makes sure that the InputStream is closed after the app is
// finished using it.
}
finally {
if (ins != null) {
ins.Close();
}
}
}
을 그리고 다음이 그대로 OnPostExecute()
방법 : 다음 DoInBackground()
방법 내에서
,이이
protected override void OnPostExecute(AsyncTaskResult<bool, Error> result) {
System.Console.WriteLine("On post execute");
}
난 그냥 AsyncTask.execute()
메소드를 호출하고 있습니다.
그리고,이 출력 무엇인지 추측 :
Done the task.
어떻게? 더 중요한 것은 어떻게 해결할 수 있습니까?
많은 사람들이 Xamarin Android 개발을 철저히 즐깁니다. 그런 의견을 말하지 마십시오. – DavidG
-1이 나온 곳입니까? –
좀 더 많은 코드를 보여줄 수 있습니까? 그 몇 줄을 감안할 때 말하기가 어렵습니다. –