/// <summary> /// 主方法 /// </summary> private void mainFunction(object arg) { init(); while (threadFlag) { updateStatusStripLeftDelegate("正在获取最新任务……"); //获取消息 string html = YongYouHandler.getToDoTaskHtmlUl(); if (html == HTTPRequests.CONN_ERR) { lock (padlock) { updateStatusStripLeftDelegate("连接内网失败,正在重连……"); updateStatusStripCenterDelegate("网络状态:无法连接办公网"); threadFlag = false; checkThread = null; startThread(); return; } } else { updateStatusStripLeftDelegate("已获取最新任务"); //显示到主页面中 updateWebBrowserDelegate(html); //获取任务列表 List <ToDoTask> toDoTasks = YongYouHandler.getToDoTasks(html); if (oldToDoTasks != null) { //找出有其中新增的任务列表 List <ToDoTask> newToDoTasks = YongYouHandler.getNewToDoTaskList(toDoTasks, oldToDoTasks); //提示新增的任务 bool wechatSuccess = alertToDoTaskList(newToDoTasks); if (!wechatSuccess) { netContectionStastion.isConnectInternet = false; updateStatusStripCenterDelegate("网络状态:办公网"); } else { netContectionStastion.isConnectInternet = true; updateStatusStripCenterDelegate("网络状态:双网"); } } oldToDoTasks = toDoTasks; updateStatusStripLeftDelegate("获取最新任务成功!"); Thread.Sleep(threadInterval); } } checkThread = null; }