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