//帐号信息查询 private void RKSignIn_Click(object sender, EventArgs e) { if (RKname.Text == "" || RKpasswd.Text == "") { SGstatus.AppendText("请输入若快账号与密码\n"); return; } var param = new Dictionary <object, object> { { "username", RKname.Text }, { "password", RKpasswd.Text } }; Thread t = new Thread(new ThreadStart(delegate { //提交服务器 string httpResult = RuoKuai.RuoKuaiHttp.Post("http://api.ruokuai.com/info.xml", param); XmlDocument xmlDoc = new XmlDocument(); try { xmlDoc.LoadXml(httpResult); } catch { SGstatus.BeginInvoke(new EventHandler(delegate { SGstatus.AppendText("返回格式有误\r\n"); SGstatus.Select(SGstatus.TextLength, SGstatus.TextLength); SGstatus.ScrollToCaret(); })); } XmlNode scoreNode = xmlDoc.SelectSingleNode("Root/Score"); XmlNode historyScoreNode = xmlDoc.SelectSingleNode("Root/HistoryScore"); XmlNode totalTopicNode = xmlDoc.SelectSingleNode("Root/TotalTopic"); XmlNode errorNode = xmlDoc.SelectSingleNode("Root/Error"); if (scoreNode != null && historyScoreNode != null && totalTopicNode != null) { SGstatus.BeginInvoke(new EventHandler(delegate { SGstatus.AppendText("剩余快豆:" + scoreNode.InnerText + "\r\n"); SGstatus.AppendText("历史快豆:" + historyScoreNode.InnerText + "\r\n"); SGstatus.AppendText("答题总数:" + totalTopicNode.InnerText + "\r\n"); SGstatus.Select(SGstatus.TextLength, SGstatus.TextLength); SGstatus.ScrollToCaret(); })); } else if (errorNode != null) { SGstatus.BeginInvoke(new EventHandler(delegate { SGstatus.AppendText("错误:" + errorNode.InnerText + "\r\n"); SGstatus.Select(SGstatus.TextLength, SGstatus.TextLength); SGstatus.ScrollToCaret(); })); } else { SGstatus.BeginInvoke(new EventHandler(delegate { SGstatus.AppendText("未知问题\r\n"); SGstatus.Select(SGstatus.TextLength, SGstatus.TextLength); SGstatus.ScrollToCaret(); })); } })); t.IsBackground = true; t.Start(); }