Measurement Studio for VC++

cancel
Showing results for 
Search instead for 
Did you mean: 

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
::PostMessage((HWND) lParam, WM_THREADFINISHED, 0, 0);

return 0; // ends the thread
}
0 Kudos
Message 1 of 2
(4,158 Views)
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
0 Kudos
Message 2 of 2
(4,158 Views)