private void Main_FormClosing(object sender, FormClosingEventArgs e) { foreach (DictionaryEntry de in (Hashtable)runtimeService.getAll().Clone()) { RuntimeEntity runtimeEntity = runtimeService.get((String)de.Key); if (runtimeEntity.getWaitQueueCnt() > 0 || runtimeEntity.getStartQueueCnt() > 0) { if (MessageBox.Show("还有任务没有完成,是否强制关闭程序?", "提醒", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.Cancel) { e.Cancel = true; } break; } } if (MailSendService.sendWaitCnt > 0 && MessageBox.Show("还有邮件正在发送,是否强制关闭程序?", "提醒", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.Cancel) { e.Cancel = true; } if (!e.Cancel) { ThreadPoolEx.destory(); } }
public static Object run(Object o) { try { Hashtable param = o as Hashtable; String url = Convert.ToString(param["url"]); try { String keyword = (String)param["type"]; parseService.changeStatus(url, Constant.ParseStatus.START); //如果RUNTIME的状态为STOP,则不再解析 if (!Constant.RunStatus.STOP.Equals(runtimeSerivce.get(url).RunStatus)) { String html = WebClientUtils.getHTML(url, Convert.ToInt32(ConfigService.get("parse.request.timeout")) * 1000); if (!"".Equals(html)) { spiderURL(html, url, keyword); spiderMail(html, keyword, url); } } parseService.changeStatus(url, Constant.ParseStatus.SUCCESS); } catch { parseService.changeStatus(url, Constant.ParseStatus.EXCEPTION); } } catch (Exception ex) { logger.Error(ex.Message, ex); } return(null); }