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

_beginthreadex创建线程的有关问题

2012-01-19 
_beginthreadex创建线程的问题编译出错:mmmView.cpp(123):errorC2664:_beginthreadex:cannotconvertparame

_beginthreadex创建线程的问题
编译出错:
mmmView.cpp(123)   :   error   C2664:   '_beginthreadex '   :   cannot   convert   parameter   3   from   'unsigned   int   (void   *) '   to   'unsigned   int   (__stdcall   *)(void   *) 'None   of   the   functions   with   this   name   in   scope   match   the   target   type

编译环境:windowsXP,VC++6.0
创建的MFC   AppWizard工程mmm,
在视图类mmmview.h文件中添加了

#include   <process.h>
protected:
        UINT     __stdcall   CommThread(LPVOID   pParam);

在mmmView.cpp文件中有如下相关代码:

void   CMmmView::OnInitialUpdate()  
{
        CView::OnInitialUpdate();

        //   TODO:   Add   your   specialized   code   here   and/or   call   the   base   class

    .......  
     
      m_pThread=(HANDLE)   _beginthreadex(NULL,0,CommThread,this,CREATE_SUSPENDED,&nDummy);//开辟外部控制线程  
      ...
}
UINT   __stdcall     CMmmView::CommThread(LPVOID     pParam)  
{  
      CMmmView   *pView   =   (CMmmView   *)pParam;  
      while(1)  
    {  
            CTime   cNowTime   =   CTime::GetCurrentTime();  
            tNow   =   cNowTime.GetTime();  
            struct   _timeb   timebuffer;  
            ftime(&timebuffer);  
            int   nNowMillSecond   =   timebuffer.millitm;  
            ///  
            tLast   =   cLastColtTime[0].GetTime();  
            if((tNow   -   tLast)*1000   +   (nNowMillSecond   -   nMillSecond[0])   >   800)  
            pView-> SetCommVal();                                            
            Sleep(100);  
      }  
}  
是哪里出了问题?
请指教,不胜感激

[解决办法]
protected:
static UINT __stdcall CommThread(LPVOID pParam);
[解决办法]
UINT __stdcall CMmmView::CommThread(LPVOID pParam) <====这里不需要__stdcall
{
CMmmView *pView = (CMmmView *)pParam;
while(1)
{
CTime cNowTime = CTime::GetCurrentTime();
tNow = cNowTime.GetTime();
struct _timeb timebuffer;
ftime(&timebuffer);
int nNowMillSecond = timebuffer.millitm;
///
tLast = cLastColtTime[0].GetTime();
if((tNow - tLast)*1000 + (nNowMillSecond - nMillSecond[0]) > 800)
pView-> SetCommVal();
Sleep(100);
}
}
在声明的时候写上
static UINT __stdcall CommThread(LPVOID pParam);

热点排行