当前位置: 首页 > news >正文

做网站维护需要学什么搜索引擎优化的工作流程是什么?

做网站维护需要学什么,搜索引擎优化的工作流程是什么?,免费建网站网址,重庆建设工程施工安全网前言#xff1a;因为项目需要定时检查网络中设备是否能连通#xff0c;需要定时去做ping操作#xff0c;若是网络不通#xff0c;则ping花费时间比较久#xff08;局域网大概4秒钟才能结束#xff0c;当然如果设置超时时间啥的#xff0c;也能很快返回#xff0c;就是会…前言因为项目需要定时检查网络中设备是否能连通需要定时去做ping操作若是网络不通则ping花费时间比较久局域网大概4秒钟才能结束当然如果设置超时时间啥的也能很快返回就是会报QProcess提前关闭的警告。此外我想要在设备连接后才去开始定时ping要是断开后则停止定时器停止ping。网上有很多定时器使用线程的例子但是没有讲到可以随时停止和开始的那种本文结合实例使用线程去执行定时器的定时操作。 一、定义定时器和线程变量。 在头文件中定义 #include QTimer#include QThread#include QString#include QProcess/** 监听网线拔出或者wifi断开情况的定时器 ***/QTimer *detectNetCablePulloutTimer NULL;/** 执行定时器的线程 **/QThread *detectNetCablePulloutTimerThread NULL;/** 开始检测网线拔出时或者wifi断开时的定时器 **/void startDetectNetCablePulloutTimer();/** 停止定时器 **/void stopDetectNetCablePulloutTimer();private slots:/** 检测网络连接情况的槽函数在线程中执行 **/void checkDeviceIsOnline(); 二、开始定时器、停止定时器以及销毁定时器代码。 开始定时器代码 void CurrentXXXClass::startDetectNetCablePulloutTimer() {// 先停止确保开始之前是停止状态stopDetectNetCablePulloutTimer();if (detectNetCablePulloutTimer NULL) {detectNetCablePulloutTimerThread new QThread(this);detectNetCablePulloutTimer new QTimer();// 5秒执行一次局域网断开时一般耗时4-5秒detectNetCablePulloutTimer-setInterval(5000);// 定时操作放在线程中执行detectNetCablePulloutTimer-moveToThread(detectNetCablePulloutTimerThread);// 定时任务放在线程中执行, 必须指定参数-Qt::DirectConnectionconnect(detectNetCablePulloutTimer, QTimer::timeout, this,CurrentXXXClass::checkDeviceIsOnline, Qt::DirectConnection);// 匿名函数void (QTimer::*pStartFun)() QTimer::start;// 线程开始时调用定时器的开始connect(detectNetCablePulloutTimerThread, QThread::started, detectNetCablePulloutTimer, pStartFun);// 线程结束时调用定时器的结束所以要停止定时器只要调用线程的quit方法// 同时防止提示定时器停止和开始不在同一线程错误connect(detectNetCablePulloutTimerThread, QThread::finished, detectNetCablePulloutTimer, QTimer::stop);}detectNetCablePulloutTimerThread-start(); } 停止定时器代码 void CurrentXXXClass::stopDetectNetCablePulloutTimer() {if (detectNetCablePulloutTimerThread ! NULL) {// 会调用定时器的stop方法detectNetCablePulloutTimerThread-quit();} } 销毁定时器在析构函数中执行 //销毁指针变量-注意先后顺序if (detectNetCablePulloutTimerThread ! NULL) {detectNetCablePulloutTimerThread-quit();detectNetCablePulloutTimerThread-wait();delete detectNetCablePulloutTimerThread;detectNetCablePulloutTimerThread nullptr;}if (detectNetCablePulloutTimer ! NULL) {delete detectNetCablePulloutTimer;detectNetCablePulloutTimer nullptr;} 三、在槽函数中执行耗时操作。 此槽函数是在子线程中执行若是执行完后要回到主线程执行某操作则必须通过发送一个信号方式才能达到效果。 void CurrentXXXClass::checkDeviceIsOnline() {QString ip 192.168.1.1;// 若是timer使用了线程则此函数在子线程中执行执行比较耗时的操作QProcess pingProcess;// 不设置-w参数QString strArg ping ip -n 1 -i 2;// qt 6 开始命令的方法pingProcess.startCommand(strArg, QIODevice::ReadOnly);// 不带等待时间参数pingProcess.waitForReadyRead();// 不带等待时间参数pingProcess.waitForFinished();QString p_stdout QString::fromLocal8Bit(pingProcess.readAllStandardOutput());bool bPingSuccess false;// 通过特殊字符串进行判断ping是否成功if (p_stdout.contains(TTL)) {// 网络连通bPingSuccess true;} else {// 网络不通bPingSuccess false;} }
http://www.pierceye.com/news/171175/

相关文章:

  • 创建个人网站的流程建设网站聊天室
  • cms 学校网站上海模板网站
  • 网站建设投资风险分析公司做的网站费用如何做账
  • 网站建设费用核算科目DW做的网页用网站打不开
  • wordpress标签搜索引擎嘉兴市做网站优化
  • 网站更换关键词怎么做好wordpress post fonts
  • 厦门优化网站排名网站备案转服务器
  • 怎样做pdf电子书下载网站做旅行攻略的网站
  • 怎样做网站推广啊抖音网站的flash怎么做
  • 网站建设小说网站建设目标是什么意思
  • 如何做一个好的网站中英文网站好处
  • wordpress站点版权设置晋中建设集团网站
  • 怎么夸一个网站做的好看烟台百度网站推广
  • 佛山市网站建设分站多少钱企业门户账号是什么
  • 大中型网站开发价格铜山区建设局局网站周保春
  • 为什么有人做商城优惠券网站卖科技风格设计网站
  • 企业网站的需求分析是做网站编辑还是做平面设计
  • 超酷 flash 网站淮南网红餐厅
  • 湛江网站建设开发株洲关键词seo优化服务商
  • 女的有没有做网站的十大经典随身空间小说推荐
  • 江西做网站哪家好监理证查询网
  • 北京驾校网站建设网络哪里能接活做网站
  • 建设网站公司排名西宁网站建设优化案例
  • 外贸网站推广有用吗网络服务投诉平台
  • 网站制作价上传下载网站模板
  • 注册网站会员 我们的信息淘宝上可以做网站吗
  • 建筑材料价格查询网站做网站从哪方面入门
  • 百度百科网站怎么做360优化大师app下载
  • 那些网站用不着做优化个人网站设计案例
  • wordpress怎么釆集文章杭州seo百度关键词排名推广