Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. AfxBeginThread and EndThread

AfxBeginThread and EndThread

Scheduled Pinned Locked Moved C / C++ / MFC
c++questionhtmlhelp
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • V Offline
    V Offline
    Vickie
    wrote on last edited by
    #1

    Dear all, I'm writting a MFC program that enables the user to enter the URL, and then press "Start" button to start downloading the html from that URL. So I have create a WorkerThread to handle the downloading process so that the user can press "Stop" button to terminate the downloading process. After successful or unsuccessful downloading of html, it should call a Text-to-speech function to speak to the user about the status of download. However, the text-to-speech function cannot work when there is another thread running. I have tried to create another thread to call the TTS function, but it failed too. My question is :where does the thread return when it finished?? Is there anyother method to call my TTS() function when the thread is finished? Here is my program: // myappdlg.cpp static UINT workerthreadcontrol ( void * pRTclass ) void myappdlg.OnStart() { downloadHTML(); } void downloadHTML() { ..... CWinThread* pWorkerThread; pWorkerThread = AfxBeginThread ( workerthreadcontrol, this, THREAD_PRIORITY_NORMAL, 0, CREATE_SUSPENDED ); m_Startbtn.EnableWindow( False ); m_Stopbtn.EnableWindow( True ); pWorkerThread->ResumeThread(); ..... } UINT workerthreadcontrol( void * pRTclass ) { myappdlg pDlg = (myappdlg*) pRTclass; pDlg->WorkerThreadProcess(); return 0; } void WorkerThreadProcess() { doing downloading......... } // Where should I put this function??? void TTS( LPCTSTR Text ) { Speak out Text..... } Thanks a lot for your help.... Best Regards, Vickie

    M 1 Reply Last reply
    0
    • V Vickie

      Dear all, I'm writting a MFC program that enables the user to enter the URL, and then press "Start" button to start downloading the html from that URL. So I have create a WorkerThread to handle the downloading process so that the user can press "Stop" button to terminate the downloading process. After successful or unsuccessful downloading of html, it should call a Text-to-speech function to speak to the user about the status of download. However, the text-to-speech function cannot work when there is another thread running. I have tried to create another thread to call the TTS function, but it failed too. My question is :where does the thread return when it finished?? Is there anyother method to call my TTS() function when the thread is finished? Here is my program: // myappdlg.cpp static UINT workerthreadcontrol ( void * pRTclass ) void myappdlg.OnStart() { downloadHTML(); } void downloadHTML() { ..... CWinThread* pWorkerThread; pWorkerThread = AfxBeginThread ( workerthreadcontrol, this, THREAD_PRIORITY_NORMAL, 0, CREATE_SUSPENDED ); m_Startbtn.EnableWindow( False ); m_Stopbtn.EnableWindow( True ); pWorkerThread->ResumeThread(); ..... } UINT workerthreadcontrol( void * pRTclass ) { myappdlg pDlg = (myappdlg*) pRTclass; pDlg->WorkerThreadProcess(); return 0; } void WorkerThreadProcess() { doing downloading......... } // Where should I put this function??? void TTS( LPCTSTR Text ) { Speak out Text..... } Thanks a lot for your help.... Best Regards, Vickie

      M Offline
      M Offline
      Michael Dunn
      wrote on last edited by
      #2

      If I understand, your problem is you need to know exactly when the worker thread has quit? Right before the return in the thread function, post a message (WM_APP would do) to your dialog to tell the UI thread that the worker thread is done. --Mike-- http://home.inreach.com/mdunn/ The preferred snack of 4 out of 5 Lounge readers.

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups