首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > VC >

写个定时器每到半夜12点自动删除一个TXT文件

2012-08-08 
写个定时器每到午夜12点自动删除一个TXT文件RT、具体应该怎么写?是不是还要用到后台线程?[解决办法]1,起来

写个定时器每到午夜12点自动删除一个TXT文件
RT、具体应该怎么写?是不是还要用到后台线程?

[解决办法]
1,起来一个线程
1,1创建一个线程类可以用:class CHostThread : public CWinThread

1,2 ,app中让线程起来:
CHostThread*m_taskThread;
m_taskThread = new CHostThread(50);
m_taskThread->Run();

2, 编写线程中:Run() 函数
int CHostThread:
{
const int nSmallTimeCycle = 60000 * 1;//1分钟检查一次时钟
int nTimeOut = 0;
 while ( true ) 
{

if ( nTimeOut >= nCheckTaskInterval ) 
{
nTimeOut = 0;
//1,判断时间当前时间是否为12:00,
//2,如果是就执行相关任务
//***** 

}
nTimeOut += nSmallTimeCycle;
Sleep(nSmallTimeCycle);

}
return CWinThread::Run();

 }

热点排行