CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    May 1999
    Posts
    92

    Killing a thread

    I have a thread that reads from my serial port and then writes the information to my active child window. The problem I am having is that If I close the child window the thread tries to write to it causing an error. I would like to know how can I kill the thread when I close the child window. I have set up my OnDestroy function to call the ExitInstance of the CWinthread derived class, but that does not stop the thread. What can I do?


  2. #2
    Join Date
    May 1999
    Posts
    19

    Re: Killing a thread

    The CWinThread function ExitInstance is a virtual function that you can override in your derived class to do any cleanup for that thread. If you read the documentation of ExitInstance(), it says not to call this function from anywhere other than the Run member function.

    If the CWinThread is a user interface thread, you can simply send a WM_QUIT message.

    -- Matt



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