Results 1 to 3 of 3

Thread: AfxBeginThread & AfxEndThread

  1. #1

    Thread Starter
    PowerPoster Chris's Avatar
    Join Date
    Jan 1999
    Location
    K-PAX
    Posts
    3,238

    Question AfxBeginThread & AfxEndThread

    In normal Win32, we can create a thread with CreateThread and therminate it anywhere with a valid thread handle will do (CloseThread).

    But in MFC, we create a thread with the AfxBeginThread and terminate it within the thread itself by AfxEndThread. So, does there any way for me to terminate the thread outside the Thread?

    regards,
    Chris.C

  2. #2
    denniswrenn
    Guest
    Can't you just create a thread like you would in a normal non-MFC Win32 App?

  3. #3
    Hyperactive Member
    Join Date
    Jul 2001
    Location
    FL
    Posts
    258
    A worker thread will end when the function ends either by return or by calling AfxEndThread with a return parameter.

    You terminate a thread from outside by decalring a handle to thread outside of the thread, then get the m_hThread member inside the thread, then you can use TerminateThread(handle) but that is dangerous.

    For a really good article on using worker threads check out this link

    http://www.codeproject.com/threads/usingworkerthreads.asp

Posting Permissions

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



Click Here to Expand Forum to Full Width