using System.Threading;//引用命名空间
//全局
Thread mythread1;
System.Threading.Timer timer;
//load加载事件
private void MainForm_Load(object sender, EventArgs e)
{
mythread1 = new Thread(new ThreadStart(RunMyThread1));
mythread1.IsBackground = true;
mythread1.Start();
}
private void RunMyThread1()
{
int time =5000; //定义5秒一次
TimerCallback timerDelagete = new TimerCallback(getJson);
timer = new System.Threading.Timer(timerDelagete, null, time, time);
}
private void getjson()
{
HttpWebRequest webRequest;
string url ="http://.......com";
webRequest = (HttpWebRequest)WebRequest.Create(url);
webRequest.Method = "GET";
webRequest.ContentType = "application/x-www-form-urlencoded";
using (HttpWebResponse response = (HttpWebResponse)webRequest.GetResponse())