公告

<2024年7月>
30123456
78910111213
14151617181920
21222324252627
28293031123
45678910

统计

  • 随笔 - 9
  • 文章 - 13
  • 评论 - 3
  • 引用 - 0

常用链接

留言簿(1)

随笔分类

随笔档案

文章分类

文章档案

搜索

  •  

最新评论

阅读排行榜

评论排行榜

/*备份----callback*/

昨日硬盘崩溃,全盘数据丢失,无法恢复,低格后少了2G的空间,因此未雨绸缪,公司的保留程序挑两个备份先。
//注释部分用了boost的线程库


typedef 
void  ( * Func)( int int );

Func CBackfunc;


void  output( int  fint,  int  frint);
// void Cfunc();
unsigned __stdcall Cfunc( void * );
void  Test();



void  main()
{
    Test();
}

/* +++++++++++++++++++++++++++++ */
// void Cfunc()
unsigned __stdcall Cfunc( void * )
{
    
int  i  =   1 ;
    
int  j  =   1 ;
    
while ( 1 )
    
{
        Sleep(
500 );
        i
++ ;
        j
++ ;
//         cout << i << j << endl;
        CBackfunc(i , j);
    }

//     return 0;
}

// ---------------------------

void  output( int  fint,  int  frint)
{
    cout 
<<   " recevie from callback function: "   <<  fint  <<   " @ "   <<  frint  <<  endl; 
}

// ------------------------------
void  Test()
{
    HANDLE hThread;
    CBackfunc 
=  output;
    hThread 
=  (HANDLE)_beginthreadex( 0 , 0 , & Cfunc, 0 , 0 , 0 );
    WaitForSingleObject( hThread, INFINITE);
//     boost::thread mythread(&Cfunc);
//     mythread.join();
}

posted on 2006-09-19 11:27 blues 阅读(131) 评论(0)  编辑 收藏 引用


只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理