110,533
社区成员
发帖
与我相关
我的任务
分享
public Thread GetMeg =null;
public void Get()
{
GetMeg = new Thread(new ThreadStart(getMessage));
GetMeg.IsBackground = true;
GetMeg.Start();
}
这是我调用获取数据的方式
public void getMessage()
{
while (true)
{
//Application.DoEvents();
{
BunnTools.FilesTool.WriteToFile(Application.StartupPath + "\\Applog.log", "消息记录:" + Environment.NewLine + DateTime.Now + " " + "执行一次 " + GetMeg.GetApartmentState().ToString(), false);
string message = GetMessage();
if (this.Messagage != null)
{
this.Messagage((message));
}
}
}
}
现在我的GetMessage();这个方式是访问http的,很耗时,我就修改成了现在的多线程循环调用,得到返回信息,委托传递给主线程,是不是我的思路就有问题呢?