Windows phone 7 HttpWebRequest.BeginGetRequestStream未异步运行
在Windows-8程序中,我调用HttpWebRequest.BeginGetRequestStream,如下所示, 以前设置过httpConnection的地方:Windows phone 7 HttpWebRequest.BeginGetRequestStream未异步运行,windows-phone-7,windows-8,Windows Phone 7,Windows 8,在Windows-8程序中,我调用HttpWebRequest.BeginGetRequestStream,如下所示, 以前设置过httpConnection的地方: private System.Net.HttpWebRequest httpConnection; public System.IO.Stream OutputStream { get { lock(syncobj) { httpConnection.B
private System.Net.HttpWebRequest httpConnection;
public System.IO.Stream OutputStream
{
get
{
lock(syncobj)
{
httpConnection.BeginGetRequestStream
(new AsyncCallback(getRequestResultCallback), null);
...
}
}
}
此代码在Windows Phone 7上运行时没有问题。由于一些同步问题
我不需要在这里讨论,我希望(要求)执行BeginGetRequestStream的代码和执行getRequestResultCallback的代码都处于启用状态
不同的线程。我认为由于getRequestResultCallback是通过
AsyncCallback,就是这样。它在Windows7中,但并不总是如此
在Windows8中。下面,我添加了一个堆栈跟踪,其中显示了一个运行
BeginGetRequestStream和getRequestResultCallback在同一线程上运行
我非常感谢任何能帮助我理解这个问题的人
提前感谢,,
约翰·爱默生
ua-desktop.exe!com.webalo.up.ua.wp.net.WpUaHttpRequest.getRequestResultCallback(System.IAsyncResult result) Line 120 C#
System.dll!System.Net.LazyAsyncResult.Complete(System.IntPtr userToken) + 0x65 bytes
System.dll!System.Net.ContextAwareResult.CaptureOrComplete(ref System.Threading.ExecutionContext cachedContext, bool returnContext) + 0x81 bytes
System.dll!System.Net.ContextAwareResult.FinishPostingAsyncOp() + 0x24 bytes
System.dll!System.Net.HttpWebRequest.BeginGetRequestStream(System.AsyncCallback callback, object state) + 0x289 bytes
ua-desktop.exe!com.webalo.up.ua.wp.net.WpUaHttpRequest.OutputStream.get() Line 31 + 0x37 bytes C#
...
mscorlib.dll!System.Threading.Tasks.Task.InnerInvoke() + 0x49 bytes
mscorlib.dll!System.Threading.Tasks.Task.Execute() + 0x32 bytes
mscorlib.dll!System.Threading.Tasks.Task.ExecutionContextCallback(object obj) + 0x15 bytes
mscorlib.dll!System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, object state, bool preserveSyncCtx) + 0xa7 bytes
mscorlib.dll!System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, object state, bool preserveSyncCtx) + 0x16 bytes
mscorlib.dll!System.Threading.Tasks.Task.ExecuteWithThreadLocal(ref System.Threading.Tasks.Task currentTaskSlot) + 0xca bytes
mscorlib.dll!System.Threading.Tasks.Task.ExecuteEntry(bool bPreventDoubleExecution) + 0xb3 bytes
mscorlib.dll!System.Threading.Tasks.Task.System.Threading.IThreadPoolWorkItem.ExecuteWorkItem() + 0x7 bytes
...
ua-desktop.exe!com.webalo.up.ua.wp.net.WpUaHttpRequest.getRequestResultCallback(System.IAsyncResult结果)第120行C#
System.dll!System.Net.LazyAsyncResult.Complete(System.IntPtr userToken)+0x65字节
System.dll!System.Net.ContextAwareResult.CaptureOrComplete(参考System.Threading.ExecutionContext cachedContext,bool returnContext)+0x81字节
System.dll!System.Net.ContextawarerResult.FinishPostingAsyncOp()+0x24字节
System.dll!System.Net.HttpWebRequest.BeginGetRequestStream(System.AsyncCallback,对象状态)+0x289字节
ua-desktop.exe!com.webalo.up.ua.wp.net.WpUaHttpRequest.OutputStream.get()行31+0x37字节C#
...
mscorlib.dll!System.Threading.Tasks.Task.InnerInvoke()+0x49字节
mscorlib.dll!System.Threading.Tasks.Task.Execute()+0x32字节
mscorlib.dll!System.Threading.Tasks.Task.ExecutionContextCallback(对象obj)+0x15字节
mscorlib.dll!System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext ExecutionContext,System.Threading.ContextCallback回调,对象状态,bool preserveSyncCtx)+0xa7字节
mscorlib.dll!System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext ExecutionContext,System.Threading.ContextCallback回调,对象状态,bool preserveSyncCtx)+0x16字节
mscorlib.dll!System.Threading.Tasks.Task.ExecuteWithThreadLocal(参考System.Threading.Tasks.Task currentTaskSlot)+0xca字节
mscorlib.dll!System.Threading.Tasks.Task.ExecuteEntry(bool bPreventDoubleExecution)+0xb3字节
mscorlib.dll!System.Threading.Tasks.Task.System.Threading.IThreadPoolWorkItem.ExecuteWorkItem()+0x7字节
...