例如,如果我在 Windows Phone 8 中有此代码
string __retS = null;
private String postRequest(String url, String postData)
{
byte[]byteData = Encoding.UTF8.GetBytes(postData);
HttpWebRequest request = null;
try
{
Uri uri = new Uri(url);
request = (HttpWebRequest)WebRequest.Create(uri);
request.Method = "POST";
request.ContentType = "application/x-www-form-urlencoded";
request.ContentLength = byteData.Length;
// start the asynchronous operation
request.BeginGetRequestStream(new AsyncCallback(GetRequestStreamCallback), request);
} // end try
catch (Exception)
{
}
return __retS;
}
我在这条线上放了一个断点request.BeginGetRequestStream(new AsyncCallback(GetRequestStreamCallback), request);
。我预计执行会跳转到我的GetRequestStreamCallback
方法,但事实并非如此。而是继续执行 return 语句,因此始终返回 null 值。
这就是它应该去的吗?