Click here to Skip to main content
15,925,133 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionRe: Navigation in MFC source code Pin
David Crow11-Aug-07 6:41
David Crow11-Aug-07 6:41 
AnswerRe: Navigation in MFC source code Pin
Mark Salsbery11-Aug-07 6:50
Mark Salsbery11-Aug-07 6:50 
QuestionMSDIA80.dll cannot be loaded Pin
Tom Thorp10-Aug-07 11:34
Tom Thorp10-Aug-07 11:34 
AnswerRe: MSDIA80.dll cannot be loaded Pin
Mark Salsbery10-Aug-07 12:03
Mark Salsbery10-Aug-07 12:03 
GeneralRe: MSDIA80.dll cannot be loaded Pin
Tom Thorp10-Aug-07 13:45
Tom Thorp10-Aug-07 13:45 
GeneralRe: MSDIA80.dll cannot be loaded Pin
Tom Thorp13-Aug-07 5:13
Tom Thorp13-Aug-07 5:13 
GeneralRe: MSDIA80.dll cannot be loaded Pin
Mark Salsbery13-Aug-07 5:35
Mark Salsbery13-Aug-07 5:35 
Questionthread communications [modified] Pin
alberthyc10-Aug-07 10:10
alberthyc10-Aug-07 10:10 
i created a mfc dialog with worker thread, i used events for communication between main thread and worker thread, but i ran into some problems i can't figure it out.

UINT ThreadFunc(LPVOID pParam)
{
THREADPARMS*ptp=(THREADPARMS*)pParam;
CWnd*pWnd=ptp->pWnd;
CMy61xxMTDlg*pDlg=ptp->pDlg;
CEvent* pKillEvent=ptp->pKillEvent;
CEvent* pOutputEvent=ptp->pOutputEvent;//ptp->pOutputEvent=&m_OutputEvent
delete ptp;


while(::WaitForSingleObject(pOutputEvent->m_hObject,1000)==WAIT_OBJECT_0)
{

pDlg->m_OutputEvent.ResetEvent();
SpcGetParam(//output some data, an external library function)

pWnd->PostMessageW(WM_USER_GET_DATA,0,0);
// i need to access GUI object-sliders, and store the positions of sliders into array, so i post a message,the handler is OnGetData()


if(::WaitForSingleObject(pKillEvent->m_hObject,0)==WAIT_OBJECT_0)
{
pWnd->PostMessageW(WM_USER_THREAD_ABORTED);
return -1;
}


return 0;
}


LRESULT CMy61xxMTDlg::OnGetData(WPARAM wParam, LPARAM lParam){
CMy61xxMTDlg*pDlg=(CMy61xxMTDlg *) GetActiveWindow();
if(pDlg!=NULL)
pDlg->GetData(pbyData[nBufIdx], BUFSIZE);

return 0;
}

void CMy61xxMTDlg::GetData(ptr8 pbyData, int32 lBufsize)
{
int i;
for (i=0; i<BUFSIZE; i ++)
{
pbyData[i]=(int8)m_Slider_Data[i].GetPos();
}
m_OutputEvent.SetEvent();
}

i set the m_OutputEvent to be manual reset, the thread wait for the signal
<pre>while(::WaitForSingleObject(pOutputEvent->m_hObject,1000)==WAIT_OBJECT_0);<pre>

then i reset the signal
<pre>pDlg->m_OutputEvent.ResetEvent();<pre>

then i post a message to run the CMy61xxMTDlg::GetData() function, which stores the slider position in the data array, at the end of the function, i signal the outputevent
<pre>m_OutputEvent.SetEvent();<pre>

the idea is that i don't want the data to be output(SpcGetParam() function) if the data is not ready yet.

i found that the loop
<pre>while(::WaitForSingleObject(pOutputEvent->m_hObject,1000)==WAIT_OBJECT_0) <pre>
only run for once, and second time the it waits(actually the program freeze a little bit) for SEVERAL seconds and jumped to "return 0" statement, which means the m_OutputEvent is not signaled,, this is quite weird....
what's happening?





-- modified at 16:56 Friday 10th August, 2007
AnswerRe: thread communications Pin
Mark Salsbery10-Aug-07 10:26
Mark Salsbery10-Aug-07 10:26 
GeneralRe: thread communications Pin
alberthyc10-Aug-07 10:32
alberthyc10-Aug-07 10:32 
GeneralRe: thread communications Pin
Mark Salsbery10-Aug-07 10:42
Mark Salsbery10-Aug-07 10:42 
GeneralRe: thread communications [modified] Pin
alberthyc10-Aug-07 10:55
alberthyc10-Aug-07 10:55 
GeneralRe: thread communications Pin
Mark Salsbery10-Aug-07 11:06
Mark Salsbery10-Aug-07 11:06 
GeneralRe: thread communications Pin
alberthyc10-Aug-07 11:17
alberthyc10-Aug-07 11:17 
GeneralRe: thread communications Pin
Mark Salsbery10-Aug-07 11:55
Mark Salsbery10-Aug-07 11:55 
GeneralRe: thread communications Pin
alberthyc10-Aug-07 16:04
alberthyc10-Aug-07 16:04 
GeneralRe: thread communications Pin
T-Mac-Oz10-Aug-07 16:44
T-Mac-Oz10-Aug-07 16:44 
GeneralRe: thread communications Pin
alberthyc11-Aug-07 8:01
alberthyc11-Aug-07 8:01 
AnswerRe: thread communications Pin
T-Mac-Oz11-Aug-07 19:37
T-Mac-Oz11-Aug-07 19:37 
AnswerRe: thread communications Pin
David Crow10-Aug-07 10:50
David Crow10-Aug-07 10:50 
QuestionDisplaying an Image(JPG,GIF) etc Pin
simon alec smith10-Aug-07 9:30
simon alec smith10-Aug-07 9:30 
AnswerRe: Displaying an Image(JPG,GIF) etc Pin
Mark Salsbery10-Aug-07 9:41
Mark Salsbery10-Aug-07 9:41 
GeneralRe: Displaying an Image(JPG,GIF) etc Pin
simon alec smith10-Aug-07 10:02
simon alec smith10-Aug-07 10:02 
QuestionRe: Displaying an Image(JPG,GIF) etc Pin
Mark Salsbery10-Aug-07 10:18
Mark Salsbery10-Aug-07 10:18 
AnswerRe: Displaying an Image(JPG,GIF) etc Pin
simon alec smith11-Aug-07 2:53
simon alec smith11-Aug-07 2:53 

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.