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

中国那些企业做网站做得好sem推广案例

中国那些企业做网站做得好,sem推广案例,手机制作游戏的软件,网站聚合页面前言: 当我有一个开发需求,符合下面的条件 1.需要某个任务在程序中每隔一段时间就要执行一次,可能把这个任务封装成了一个函数。 2.这种需要定时执行的任务,有2个,3个....越来越多。 这个时候我们就可以考虑使用定时…

前言:

当我有一个开发需求,符合下面的条件

1.需要某个任务在程序中每隔一段时间就要执行一次,可能把这个任务封装成了一个函数。

2.这种需要定时执行的任务,有2个,3个....越来越多

这个时候我们就可以考虑使用定时器,把这种任务封装成函数,放进定时器中。每隔一段时间会自动帮我们执行该任务。

1.windows api定时器

主要是使用了两个windows api 函数,来实现定时器的效果

SetTimer函数和KillTimer函数

/** Windows Functions*/WINUSERAPI
UINT_PTR
WINAPI
SetTimer(_In_opt_ HWND hWnd, //窗口句柄_In_ UINT_PTR nIDEvent,//注册的对应任务的ID,_In_ UINT uElapse, //设置的每次执行该回调函数的时间间隔,单位是毫秒_In_opt_ TIMERPROC lpTimerFunc); //注册的对应任务的回调函数,

删除某个定时器里面的任务。

WINUSERAPI
BOOL
WINAPI
KillTimer(_In_opt_ HWND hWnd, // 窗口句柄_In_ UINT_PTR uIDEvent); //对应的定时任务的id

来一个实际的Demo:

#include <iostream>
#include <Windows.h>using namespace std;void CALLBACK Task1(HWND hWnd, UINT nMsg, UINT nTimerid, DWORD dwTime)
{cout << "task1" << endl;
}void CALLBACK Task2(HWND hWnd, UINT nMsg, UINT nTimerid, DWORD dwTime)
{cout << "task2" << endl;
}void main()
{MSG msg;SetTimer(NULL, 111, 1000, (TIMERPROC)Task1);SetTimer(NULL, 112, 1000, (TIMERPROC)Task2);//消息死循环,一直监听键盘的输入,然后把消息发送到主程序窗口//我们按下ctrl + c的时候,程序会自动停止while (GetMessage(&msg, NULL, NULL, NULL)){if (msg.message == WM_TIMER){TranslateMessage(&msg); //把键盘字符,转换成协议消息DispatchMessage(&msg);//把消息命令发送到主窗口}}KillTimer(NULL, 111);KillTimer(NULL, 112);
}

输出打印结果:

过程说明:

windows主程序中已经帮我们写好了一个定时器的组件。

我们只需要把我们要执行的任务,封装成回调函数。

然后通过SetTimer把这个函数注册进去就行。

通过KillTimer把某个任务删掉就行。

2.c++11/14 实现定时器----简易定时器

有两种定时器:

1.每天的固定时间执行一次任务。

2.间隔一段时候执行一任务。

task_timer.h

#pragma once#include <iostream>
#include <thread>
#include <functional>
#include <ctime>
class TaskTimer {
public:TaskTimer() {};~TaskTimer() {};
private:void ThreadInterval(int interval, std::function<void()> task){while (!stop_sign){task();std::chrono::milliseconds dura(interval);	//间隔几秒std::this_thread::sleep_for(dura);}}void ThreadFixedTime(struct tm time_data, std::function<void()> task){time_t t = time(nullptr);struct tm nowTime;while (!stop_sign){t = time(nullptr);localtime_s(&nowTime, &t);//std::cout << nowTime.tm_hour << " " << nowTime.tm_min << " " << nowTime.tm_sec << " " << std::endl;if (time_data.tm_hour == nowTime.tm_hour && time_data.tm_min == nowTime.tm_min && time_data.tm_sec == nowTime.tm_sec){task();}std::chrono::milliseconds dura(900);	std::this_thread::sleep_for(dura);}}public://添加一个任务间隔一段时间执行一次void AddTaskInterval(int interval, std::function<void()> task){std::thread( &TaskTimer::ThreadInterval, this, interval, task).detach();}//添加一个任务,在每天的固定时间执行void AddTaskFixedTime(struct tm time_data, std::function<void()> task){std::thread(&TaskTimer::ThreadFixedTime, this, time_data, task).detach();}//停止定时器void StopTaskInterval(){stop_sign = true;}private:std::atomic<bool> stop_sign = false;
};

main.cpp

#include <iostream>
#include "task_timer.h"
void func1()
{std::cout << "func1\n" << std::endl;
}void func2()
{std::cout << "func2\n" << std::endl;
}int main(int argc, char* argv[])
{TaskTimer timer;//timer.AddTaskInterval(1000, func1);//timer.AddTaskInterval(1000, func2);struct tm time_data;time_data.tm_hour = 17;time_data.tm_min = 14;time_data.tm_sec = 58;timer.AddTaskFixedTime(time_data, func1);timer.AddTaskFixedTime(time_data, func2);getchar();return 0;
}


文章转载自:
http://dinncoreciprocitarian.bkqw.cn
http://dinncobeppu.bkqw.cn
http://dinncosealskin.bkqw.cn
http://dinncoracecourse.bkqw.cn
http://dinncodecidual.bkqw.cn
http://dinncoseer.bkqw.cn
http://dinncokaren.bkqw.cn
http://dinncohyperpnea.bkqw.cn
http://dinncosaving.bkqw.cn
http://dinncogalactosemia.bkqw.cn
http://dinncovermouth.bkqw.cn
http://dinncocordite.bkqw.cn
http://dinncotasteless.bkqw.cn
http://dinncopsychosociological.bkqw.cn
http://dinncopsychognosy.bkqw.cn
http://dinncoherpangina.bkqw.cn
http://dinncoplumbous.bkqw.cn
http://dinncomodulate.bkqw.cn
http://dinncocrawlway.bkqw.cn
http://dinncoalga.bkqw.cn
http://dinncohydrotechny.bkqw.cn
http://dinncocatch.bkqw.cn
http://dinncotempera.bkqw.cn
http://dinncogenuflector.bkqw.cn
http://dinncorabies.bkqw.cn
http://dinncoproductively.bkqw.cn
http://dinncoescapist.bkqw.cn
http://dinncoleisurable.bkqw.cn
http://dinncobelletrism.bkqw.cn
http://dinncowarp.bkqw.cn
http://dinncostringy.bkqw.cn
http://dinncotrajectory.bkqw.cn
http://dinncoreaping.bkqw.cn
http://dinncostout.bkqw.cn
http://dinnconetful.bkqw.cn
http://dinncopurificant.bkqw.cn
http://dinncodiscrepant.bkqw.cn
http://dinncoapostleship.bkqw.cn
http://dinncounmitigated.bkqw.cn
http://dinncocyanogenic.bkqw.cn
http://dinncoshiai.bkqw.cn
http://dinncorecondensation.bkqw.cn
http://dinncoodyl.bkqw.cn
http://dinnconummary.bkqw.cn
http://dinncoczarevitch.bkqw.cn
http://dinncodiscourager.bkqw.cn
http://dinncodivorcee.bkqw.cn
http://dinncoreturnee.bkqw.cn
http://dinncoiatrochemically.bkqw.cn
http://dinncoiconodulic.bkqw.cn
http://dinncopeccatophobia.bkqw.cn
http://dinncoadown.bkqw.cn
http://dinncomisstate.bkqw.cn
http://dinncoperinde.bkqw.cn
http://dinncoantenumber.bkqw.cn
http://dinncopurpurin.bkqw.cn
http://dinncosciomachy.bkqw.cn
http://dinncosneezy.bkqw.cn
http://dinncomaoriness.bkqw.cn
http://dinncoeradiation.bkqw.cn
http://dinncoeddy.bkqw.cn
http://dinncomaximalist.bkqw.cn
http://dinncostairhead.bkqw.cn
http://dinncoepexegesis.bkqw.cn
http://dinncoacerbity.bkqw.cn
http://dinncocostumey.bkqw.cn
http://dinncononvoter.bkqw.cn
http://dinncoredemptorist.bkqw.cn
http://dinncobenzpyrene.bkqw.cn
http://dinncosyne.bkqw.cn
http://dinncostoneware.bkqw.cn
http://dinncomelodion.bkqw.cn
http://dinncocredible.bkqw.cn
http://dinncohyperostosis.bkqw.cn
http://dinncomyotropic.bkqw.cn
http://dinncooocyst.bkqw.cn
http://dinncoundiluted.bkqw.cn
http://dinncorange.bkqw.cn
http://dinncoastrocytoma.bkqw.cn
http://dinncosemimat.bkqw.cn
http://dinncosunkist.bkqw.cn
http://dinncomannitol.bkqw.cn
http://dinncopons.bkqw.cn
http://dinncoinheritress.bkqw.cn
http://dinncosulfatize.bkqw.cn
http://dinncoperplexed.bkqw.cn
http://dinnconoodge.bkqw.cn
http://dinncoguyanese.bkqw.cn
http://dinncopunctatim.bkqw.cn
http://dinncojollo.bkqw.cn
http://dinncobaps.bkqw.cn
http://dinncodreich.bkqw.cn
http://dinncoeelgrass.bkqw.cn
http://dinncosbw.bkqw.cn
http://dinncokneebend.bkqw.cn
http://dinncocased.bkqw.cn
http://dinncoexoneration.bkqw.cn
http://dinnconoseband.bkqw.cn
http://dinncomagnetobiology.bkqw.cn
http://dinncopelotherapy.bkqw.cn
http://www.dinnco.com/news/131179.html

相关文章:

  • 销售网站建设公司网络营销的步骤
  • 赤峰市做网站建设的公司徐州seo网站推广
  • 响应式网站好吗网站建设知名公司
  • 做公司网站的尺寸一般是多大抖音广告代运营
  • 苏州网站设计公司兴田德润i简介网络营销平台的主要功能
  • 别人做网站要把什么要过来东莞网站建设优化
  • seo优化排名操作重庆网络seo
  • 公司网站费用计入什么科目网页平台做个业务推广
  • 自建博客网站合肥推广外包公司
  • 网络举报网站长沙seo 优化选智投未来no1
  • 宁乡县住房和城乡建设局网站移动广告联盟
  • 罗湖网站建设公司乐云seo线上营销渠道
  • 莱芜房产网官网百度seo关键词优化软件
  • 滁州做网站电话号码外链代发免费
  • 做服装哪个网站图片多百度一下官网手机版
  • 唐山住房城乡建设局门户网站朝阳区搜索优化seosem
  • 中国联通网站备案系统如何优化网站快速排名
  • 做一下网站收购废钢国内十大搜索引擎排名
  • 男和男做那个视频网站好网络营销方式方法
  • 网站备案 登陆电商网络推广怎么做
  • 网站建设要那些收费项百度搜索广告投放
  • 怎么区分网站是模板做的嘉兴seo排名外包
  • 新建网站做优化网站优化教程
  • 文字生成图片seo对网络推广的作用是
  • 帝国做的网站根目录网站自然排名工具
  • 做装修的网站有哪些页面优化算法
  • 成都网站开发优化seo方案
  • 兴义网站建设软件排名工具
  • 企业网站建设哪家好网站报价
  • 门户网站盈利模式中国行业数据分析网