+ Reply to Thread
Results 1 to 2 of 2

Thread: Create a simple thread using MFC

  1. #1
    Junior Member
    Join Date
    Apr 2012
    Posts
    38

    Create a simple thread using MFC

    How can I create a thread using MFC? Please provide me simple way to create a background thread in MFC. Thanks in advance.

  2. #2
    Use "AfxBeginThread" to create a thread in MFC application.

    Useful example:

    Code:
    UINT WINAPI MFCThreadFunc(void *pParam)
    {
    	OutputDebugString("Hello World from first MFC thread!!\n") ;
    	return 0 ;
    }
    
    BOOL CMFCDlg::OnInitDialog()
    {
    	CDialog::OnInitDialog();
    	AfxBeginThread((AFX_THREADPROC) MFCThreadFunc, NULL, 0, 0, 0, NULL) ;
    	return TRUE;  
    }
    Thanks.

+ Reply to Thread

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts