繁体   English   中英

由于对象的当前状态,AsyncCallback和操作无效

[英]AsyncCallback & Operation is not valid due to the current state of the object

我收到错误消息, Operation is not valid due to the current state of the object. 在下面的示例的最后一行。

HttpWebRequest myRequest = (HttpWebRequest)HttpWebRequest.Create(myUri);
myRequest.BeginGetRequestStream(new AsyncCallback(GetRequestStreamCallback), Tuple.Create(myRequest, Jtype.session_get));
myRequest.BeginGetRequestStream(new AsyncCallback(GetRequestStreamCallback), Tuple.Create(myRequest, Jtype.session_stats));

我想这与以下事实有关:我不为每个BeginGetRequestStream使用线程,但我不太确定。 为什么会出现此错误? 我该如何解决?

先感谢您

您不能使用相同的myRequest对象来启动两个异步Http调用。 如果必须同时进行两个异步调用,请使用HttpWebRequest另一个实例。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM