9/08/2012

Making thread on MFC (example source code)

Simple source code

//Declaration
static UINT Thread(LPVOID pParam);


//Definition
UINT Thread(LPVOID pParam)
{
     //Thread Part 
     while( ((GUIView*)pParam)->Thread_B )
    {
        //Time delay
        Sleep(100);

        //Processing
        ((GUIView*)pParam)->DoProcessing(); 
      }

      return 0;
}


//Thread Begin 
void GUIView::BegainThread()
{
     Thread_B = true;
     ::AfxBeginThread(Thread, this);
}