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. I want to run thread at regular interval in multimedia timer,how should i do?please tell me the better approch

I want to run thread at regular interval in multimedia timer,how should i do?please tell me the better approch

Scheduled Pinned Locked Moved C / C++ / MFC
helpquestioncareer
3 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.
  • A Offline
    A Offline
    anilaabc
    wrote on last edited by
    #1

    I want to do two to three tasks at the same time at regular interval ,time is important so i m using multimedia timer . problem is ....timer run the thread only once .code is below when I click button thread is created and multimedia timer is set. count is an integer initialized with 0. I suspend thread to resume at regular interval . void CTimerDlg::Onbtnstart() { Thread=AfxBeginThread(ThreadDisplay, this, THREAD_PRIORITY_TIME_CRITICAL,0 ,CREATE_SUSPENDED); handle=Thread->m_hThread; Thread->m_bAutoDelete=false; timeSetEvent(100, 0, TimeProcVideo, (DWORD)this, TIME_PERIODIC); } //thread analyzing data UINT ThreadDisplay(LPVOID lParam) { CTimerDlg *obj=(CTimerDlg*) lParam; obj->abc(); return 1; } void CTimerDlg::abc() { count++; char a[20]; GetDlgItem(IDC_STATIC)->SetWindowText(""); CString s=itoa(count,a,10); GetDlgItem(IDC_STATIC)->SetWindowText(s); SuspendThread(handle); } void CALLBACK TimeProcVideo(UINT uID, UINT uMsg, DWORD dwUser, DWORD dw1, DWORD dw2) { CTimerDlg* timer=(CTimerDlg*) dwUser; timer->ControlThreads(); } void CTimerDlg::ControlThreads() { ResumeThread(handle); }

    G 1 Reply Last reply
    0
    • A anilaabc

      I want to do two to three tasks at the same time at regular interval ,time is important so i m using multimedia timer . problem is ....timer run the thread only once .code is below when I click button thread is created and multimedia timer is set. count is an integer initialized with 0. I suspend thread to resume at regular interval . void CTimerDlg::Onbtnstart() { Thread=AfxBeginThread(ThreadDisplay, this, THREAD_PRIORITY_TIME_CRITICAL,0 ,CREATE_SUSPENDED); handle=Thread->m_hThread; Thread->m_bAutoDelete=false; timeSetEvent(100, 0, TimeProcVideo, (DWORD)this, TIME_PERIODIC); } //thread analyzing data UINT ThreadDisplay(LPVOID lParam) { CTimerDlg *obj=(CTimerDlg*) lParam; obj->abc(); return 1; } void CTimerDlg::abc() { count++; char a[20]; GetDlgItem(IDC_STATIC)->SetWindowText(""); CString s=itoa(count,a,10); GetDlgItem(IDC_STATIC)->SetWindowText(s); SuspendThread(handle); } void CALLBACK TimeProcVideo(UINT uID, UINT uMsg, DWORD dwUser, DWORD dw1, DWORD dw2) { CTimerDlg* timer=(CTimerDlg*) dwUser; timer->ControlThreads(); } void CTimerDlg::ControlThreads() { ResumeThread(handle); }

      G Offline
      G Offline
      Garth J Lancaster
      wrote on last edited by
      #2

      you were given an answer by Roger the first time you asked this question (some 21 hrs ago as I see it). If you cant be bothered answering him/explaining what you're trying to do, dont post the same question again !!! 'g'

      A 1 Reply Last reply
      0
      • G Garth J Lancaster

        you were given an answer by Roger the first time you asked this question (some 21 hrs ago as I see it). If you cant be bothered answering him/explaining what you're trying to do, dont post the same question again !!! 'g'

        A Offline
        A Offline
        anilaabc
        wrote on last edited by
        #3

        I think you didn't noticed.I modified the question and explained ...

        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