private void timer1_Tick(object sender, EventArgs e) { string html = "failed"; while (html == "failed") { html = RequsetHelper.GetHtml(Cookie.email, Cookie.key, Cookie.uid, Cookie.expire_in); } Refresh(); }
private void Refresh(Action errorHandle) { int flag = 0; string html = "failed"; while (html == "failed") { html = RequsetHelper.GetHtml(Cookie.email, Cookie.key, Cookie.uid, Cookie.expire_in); if (flag > 5) { MessageBox.Show("连接超时"); return; } } if (!html.Contains("总流量")) { errorHandle(); return; } message = TextHelper.GetMessage(html, out double percent); notifyIcon1.Icon = ImageHelper.MakeIcon(percent); notifyIcon1.Text = String.Format("用户名:{0}\r\n用户等级:{1}\r\n总流量:{2}\r\n已用流量:{3}\r\n剩余流量:{4}", message.Username, message.Level, message.All, message.Used, message.Surplus); this.Visible = false; }