Measurement Studio for VC++

cancel
Showing results for 
Search instead for 
Did you mean: 

Multithreaded Application on a Multiprocessor System

I have a multithreaded application that uses a Measurement Studio CWGraph control. The application was compiled on a single processor system. It runs ok on all the single processor system that I have installed the application on. I finally got around to trying it on a multiprocessor system and it died. Before the system locked up I saw a message indicating that the component was a demo version. Any thoughts?

Thanks,
Lyle
0 Kudos
Message 1 of 3
(3,170 Views)
Ok, I have some thoughts and opinions...

1. If you built your app with version 6.x of CW and have used 1.x before, you probably have the wrong version of CWUI.OCX registered on the dual proc. machine. Or... You are creating your graph dynamically via Create() and you will need to supply the registration info to the control. (I think NI has some info on this somewhere...)

2. The 1.x version of the CWGraph control is not thread-safe. I believe NI made it so that v6.x controls are. However.... I strongly recomment that you never touch a GUI control from a worker thread. In general it is just bad coding practice and is begging for undefined behavior and possible thread lock. If you really need to talk to the GUI via seperate threads, I suggest using ::PostMe
ssage() and custom WM_APP defined messages. Don't use ::SendMessage() because that waits for the message handler to return before continuing and if the handler dies or never returns, your thread is locked. PostMessage just sends the message on its way and the thread moves on. Remember you need to make sure your pointers are not destroyed by the posting thread before the handler gets to use them. In this context, you should "new" your pointers in the calling thread and "delete" them in the handler. Be very careful though so that you don't create memory leaks!

Good luck.
0 Kudos
Message 2 of 3
(3,170 Views)
It would be nice if the documentation for every function call had a note as to whether or not it
was threadsafe.
0 Kudos
Message 3 of 3
(3,170 Views)