当前位置: 代码迷 >> VC >> 写个定时器每到夜半12点自动删除一个TXT文件
  详细解决方案

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

热度:1526   发布时间:2013-02-25 00:00:00.0
写个定时器每到午夜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();

 }

  相关解决方案