09-05-2012 03:02 AM - edited 09-05-2012 03:03 AM
Hello, When request CallBack it is error "System.Net.WebException: The operation has timed out."
![]()
AppMainUpdate
{
.....
WClient.SendQuery();
.....
}
-----------------------------------------------
public static class WClient {
private static Queue<UriPack> QueueList = new Queue<UriPack> ();
private static Dictionary<string,EventHandler> DicRequest =new Dictionary<string, EventHandler> (); private static String TimeInfoUri = "http://www.xxx.com.cn/data/sk/{0}.html";
private static String CurrentKey;
private static Uri CurrentUri;
private static bool isNext = true;
private static void AddRequest (Uri uriStr, EventHandler e) {
string key = Guid.NewGuid ().ToString ();
DicRequest.Add (key, e);
lock (QueueList) {
QueueList.Enqueue (new UriPack (key, uriStr));
}
}
public static void SendQuery () {
lock (QueueList) {
if (QueueList.Count > 0) {
if (isNext) {
isNext = false;
SendQuerySpeed (QueueList.Dequeue());
}
}
}
}
public static void SendQuerySpeed (UriPack site) {
CurrentKey = site.Key;
CurrentUri = site.UriStr;
var request = HttpWebRequest.Create (CurrentUri);
request.Timeout=10000;
request.BeginGetResponse (new AsyncCallback (requestCallBack), request);
}
/// <summary>
/// 处理下载事件
/// </summary>
/// <param name="sender"></param>
/// <param name="args"></param>
static void requestCallBack (IAsyncResult ar) {
string tempstr="";
var webRequest = (HttpWebRequest)ar.AsyncState;
using(var webResponse = (HttpWebResponse)webRequest.EndGetResponse (ar)) {
using(var stream = webResponse.GetResponseStream()) {
using(var sr=new StreamReader(stream)) {
tempstr=sr.ReadToEnd(); // time out!!
}
}
}
DicRequest [CurrentKey] (tempstr, null);
DicRequest.Remove (CurrentKey);
isNext = true;
}
}
Solved! Go to Solution.
on 09-05-2012 12:03 PM
I find the reason, only the first request this error, request willsucceed next time
PSM Developer Registration (for free) on PSM DevPortal is required to post on the forum.
Please sign out then sign in again to the forum and PSM DevPortal after you have completed the registration.
フォーラムへ投稿をするにはPSM DevPortalへの登録(無料)が必要です。
登録後はフォーラムと
PSM DevPortalを一度ログアウトし、再度ログインしてください。


Website ©2013 Sony Computer Entertainment Europe
All content, game titles, trade names and/or trade dress, trademarks, artwork and associated imagery are trademarks and/or copyright material of their respective owners. All rights reserved. [more info]
%%http://community.eu.playstation.com/t5/Announcements/Beta-Trial-Information/td-p/11386362
best_shooter.png%%http://community.eu.playstation.com/t5/Announcements/Introducing-Best-of-PlayStation/td-p/13741979
best_driver.png%%http://community.eu.playstation.com/t5/Announcements/Introducing-Best-of-PlayStation/td-p/13741979
best_performer.png%%http://community.eu.playstation.com/t5/Announcements/Introducing-Best-of-PlayStation/td-p/13741979
best_footballer.png%%http://community.eu.playstation.com/t5/Announcements/Introducing-Best-of-PlayStation/td-p/13741979
best_fighter.png%%http://community.eu.playstation.com/t5/Announcements/Introducing-Best-of-PlayStation/td-p/13741979
best_creator.png%%http://community.eu.playstation.com/t5/Announcements/Introducing-Best-of-PlayStation/td-p/13741979
best_action_player.png%%http://community.eu.playstation.com/t5/Announcements/Introducing-Best-of-PlayStation/td-p/13741979
dev2.png%%http://community.eu.playstation.com/t5/Website-and-Forum-Help-Feedback/Producer-and-Developer-Ranks/td-p/18407352
trophy.gif%%http://community.eu.playstation.com/t5/Website-and-Forum-Help-Feedback/The-Community-Awards-FAQ/td-p/18407096
PSlogoSM.png%%http://community.eu.playstation.com/t5/Website-and-Forum-Help-Feedback/Online-Support-Coordinator-rank/td-p/18414870