NI Home > Community > NI Discussion Forums

Measurement Studio for VC++

Reply
Member
lodestar
Posts: 1
0 Kudos

ComponentWorks++ (MultiThread):Why Do I get "Unhanled exception (Kernel32.dll): Microsoft C++ Exception", when try plotting into the worker thread?

Visual C++ (componentwork++):
My worker thread:

UINT GetDataThreadProc(LPVOID lParam)
{
double value;

double Data[100];
CMyDlg *pWnd = (CMyDlg *)lParam;




::WaitForSingleObject(g_eventStart.m_hObject, INFINITE);
TRACE("starting computation\n");
while(g_iBeginGetDataProc)
{
for (int ptIndex = 0; ptIndex < 100; ptIndex++)
{
const double maxValue = 10.0;
value = (double)rand()/RAND_MAX * maxValue;
Data[ptIndex] = value;

TRACE (" %d %f\n", ptIndex, Data[ptIndex]);
}
TRACE ("Ok\n");
//---------------------------------------------------
-----------------------
// plot the time domain data
//--------------------------------------------------------------------------
pWnd->m_timeDomainGraph.PlotY(CNiReal64Matrix(1, 100, Data));


if (::WaitForSingleObject(g_eventKill.m_hObject, 0) == WAIT_OBJECT_0)
{
TRACE ("Break\n");
break;
}

}
// tell owner window we're finished
::smileytongue:ostMessage((HWND) lParam, WM_THREADFINISHED, 0, 0);

return 0; // ends the thread
}
Active Participant
Chris Matthews
Posts: 1,168
0 Kudos

Re: ComponentWorks++ (MultiThread):Why Do I get "Unhanled exception (Kernel32.dll): Microsoft C++ Exception", when try plotting into the worker thread?

The current version of the Tools for Visual C++ do not support access of our UI ActiveX controls from multiple threads. The next version should have support for this. This is discussed in detail in the KB here:
http://digital.ni.com/public.nsf/3efedde4322fef19862567740067f3cc/b6d0e197b90fc2048625699f006fa5ce?OpenDocument

There is also an example of the workaround for this problem here:

http://zone.ni.com/devzone/devzone.nsf/webcategories/61B119A9F74ADC07862568C50070CE22?opendocument

Best Regards,

Chris Matthews
Measurement Studio Support Manager