CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Jan 2008
    Location
    India
    Posts
    408

    Question Kill a thread started by AfxBeginThread

    Code:
    CWinThread* myThread;
    myThread = AfxBeginThread(ThreadFunction, this, THREAD_PRIORITY_NORMAL, 0, 0);
    


    If I want to kill this thread, how to do that?

    Thanks
    Rate the posts which you find useful

  2. #2
    Join Date
    Apr 2008
    Posts
    133

    Re: Kill a thread started by AfxBeginThread

    To kill the thread get the thread handle m_hThread from myThread and call TerminateThread on the handle. Be warned though that terminating threads in this fashion is not recommended, the proper way is to signal your thread somehow to close on its own and wait for its closure in the main thread.

Tags for this Thread

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

Featured