Click here to Skip to main content
15,902,889 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: Help with threads Pin
David Crow6-Sep-12 5:41
David Crow6-Sep-12 5:41 
QuestionRe: Help with threads Pin
AndrewG123111-Sep-12 11:33
AndrewG123111-Sep-12 11:33 
QuestionRe: Help with threads Pin
David Crow12-Sep-12 2:45
David Crow12-Sep-12 2:45 
GeneralRe: Help with threads Pin
AndrewG123112-Sep-12 6:21
AndrewG123112-Sep-12 6:21 
SuggestionRe: Help with threads Pin
David Crow12-Sep-12 8:17
David Crow12-Sep-12 8:17 
QuestionRe: Help with threads Pin
AndrewG123112-Sep-12 14:21
AndrewG123112-Sep-12 14:21 
AnswerRe: Help with threads Pin
David Crow13-Sep-12 3:47
David Crow13-Sep-12 3:47 
GeneralRe: Help with threads Pin
AndrewG123113-Sep-12 7:46
AndrewG123113-Sep-12 7:46 
Here is the exact compiler message of the error.
Dlg_SpectrumAnalyzer.cpp(150): error C2227: left of '->m_hObject' must point to class/struct/union/generic type
1>Dlg_SpectrumAnalyzer.cpp(153): error C2227: left of '->SetEvent' must point to class/struct/union/generic type
1>Dlg_SpectrumAnalyzer.cpp(154): error C2561: 'CDlg_SpectrumAnalyzer::Acq_Data' : function must return a value

However, I implemented you suggestion a bit differently. I did not use void Acq_DAta(void) instead I have incorporated everything in the following member.
UINT CDlg_SpectrumAnalyzer::Acq_Data(LPVOID pParam)
{
	
	CDlg_SpectrumAnalyzer *dlg =(CDlg_SpectrumAnalyzer*) pParam;
	HWND hdlg = dlg->GetSafeHwnd();
	// start data ACQ
	while(1)
	{
	     if (WaitForSingleObject(m_pEventStopRequested->m_hObject, 0U) == WAIT_OBJECT_0)
             {
            // let OnClick() know that the secondary thread is not running
            m_pEventThreadDone->SetEvent();
            return;
	     }
	     else
	     {
			
		dlg->m_inst->ADCdbRead(dlg->m_AcqChan,dlg->m_MaxFreq*2,dlg->m_BuffSize,dlg->m_fulldata,dlg->m_halfdata);
		while(dlg->m_Continue && ! dlg->m_inst->m_Flags.Halt)
			dlg->m_inst->ADCdbInquire(dlg-   >m_halfdata,hdlg,MSG_DRAW_SPECTRUM);

			dlg->m_inst->ADCdbStop();
			//release instrument
			dlg->m_inst->EndOperation();
			
			return 1;
	     }
		 
	}

}
Here is the button control code.
void CDlg_SpectrumAnalyzer::OnBnClickedRun()
{
	// TODO: Add your control notification handler code here
	 if (WaitForSingleObject(m_pEventThreadDone->m_hObject, 0U) == WAIT_OBJECT_0)
    {
        // at this point, you could disable the button that
        // started this so that it could not be clicked again

        // set the STOP and DONE events to nonsignaled (haven't happened yet)
        m_pEventStopRequested->ResetEvent();
        m_pEventThreadDone->ResetEvent();
 
        // start the secondary thread
        m_pThread = AfxBeginThread(Acq_Data, this, THREAD_PRIORITY_HIGHEST);
    }
		
}
Have I done something foolish in the way I was trying to use your suggestion?

modified 13-Sep-12 13:54pm.

GeneralRe: Help with threads Pin
David Crow13-Sep-12 7:55
David Crow13-Sep-12 7:55 
GeneralRe: Help with threads Pin
AndrewG123113-Sep-12 8:54
AndrewG123113-Sep-12 8:54 
QuestionRe: Help with threads Pin
David Crow13-Sep-12 9:32
David Crow13-Sep-12 9:32 
AnswerRe: Help with threads Pin
AndrewG123127-Sep-12 12:02
AndrewG123127-Sep-12 12:02 
GeneralRe: Help with threads Pin
David Crow28-Sep-12 2:13
David Crow28-Sep-12 2:13 
GeneralRe: Help with threads Pin
Albert Holguin5-Sep-12 12:22
professionalAlbert Holguin5-Sep-12 12:22 
QuestionStructure containing byte[1] as member variable Pin
Rahul from Poona4-Sep-12 8:45
Rahul from Poona4-Sep-12 8:45 
AnswerRe: Structure containing byte[1] as member variable Pin
Chris Losinger4-Sep-12 8:59
professionalChris Losinger4-Sep-12 8:59 
GeneralRe: Structure containing byte[1] as member variable Pin
jschell4-Sep-12 11:32
jschell4-Sep-12 11:32 
GeneralRe: Structure containing byte[1] as member variable Pin
Chris Losinger4-Sep-12 11:42
professionalChris Losinger4-Sep-12 11:42 
GeneralRe: Structure containing byte[1] as member variable Pin
jschell5-Sep-12 11:28
jschell5-Sep-12 11:28 
GeneralRe: Structure containing byte[1] as member variable Pin
Chris Losinger5-Sep-12 11:51
professionalChris Losinger5-Sep-12 11:51 
GeneralRe: Structure containing byte[1] as member variable Pin
jschell6-Sep-12 8:31
jschell6-Sep-12 8:31 
GeneralRe: Structure containing byte[1] as member variable Pin
Chris Losinger6-Sep-12 9:19
professionalChris Losinger6-Sep-12 9:19 
GeneralRe: Structure containing byte[1] as member variable Pin
jschell13-Sep-12 8:07
jschell13-Sep-12 8:07 
GeneralRe: Structure containing byte[1] as member variable Pin
Chris Losinger13-Sep-12 8:11
professionalChris Losinger13-Sep-12 8:11 
GeneralRe: Structure containing byte[1] as member variable Pin
jschell14-Sep-12 8:41
jschell14-Sep-12 8:41 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.