2014-11-24 69 views
0

我得到的錯誤Operation is not valid due to the current state of the object.在下面的示例中的最後一行的當前狀態..的AsyncCallback和操作無效由於對象

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,但我不完全確定..任何想法請嗎?爲什麼我得到這個錯誤?我如何解決它?

預先感謝您

+0

也許你不允許在它已經啓動的時候使用相同的請求對象來啓動請求嗎?你有沒有想過? – mostruash 2014-11-24 21:31:31

回答

0

不能使用相同的myRequest對象發出兩個異步HTTP調用。 如果您必須一起進行兩個異步調用,則使用另一個HttpWebRequest實例。

相關問題