11-13-2005 09:32 PM
11-14-2005 07:58 AM
It took me a lot of work to get a definative answer to that Q.
Yes, VI server executes in the UI thread.
11-15-2005 08:15 AM
Hi Greg,
I was wondering if you have time to answer one question in the NI discussion forums.
You have an understanding of this subject and I need to understand it.
http://forums.ni.com/ni/board/message?board.id=170&message.id=151543
Basically what all happens when a dynamic call is made. Is the client in the UI thread, Is the server in the UI thread.
Is the client a STA or an MTA. Is the server a STA or an MTA. If there is a hold up are the messages held up in the
Windows message queue ?
Lastly, How do you get around a backup in the queue?
Thanks Much
Chuck Streb
11-15-2005 08:34 AM
11-15-2005 08:47 AM
11-15-2005 09:19 AM
I wouldn't say I understand this exactly because I don't have much background on what action is being performed.
Here is some background.
The VI server is executed largely within the UI thread -- reason is that since some things need to be synchronized and protected, this acts as the primary gateway. Many of the operations will move to other threads once they pass through the VI Server gateway.
If you are using a Call by Reference node from a LV diagram to call a local VI, ActiveX is not involved unless some of the datatypes are ActiveX variants. The diagram containing the Call by Ref node could be running in any thread. And in fact, many diagrams could be requesting that the subVI be executed -- some of those diagrams can even be from other computers. So, the call is posted to the UI thread so that the VI server can pick the first one to call the subVI. The parameters are copied into the subVI, and the subVI is scheduled to run wherever it likes -- not necessarily in the UI thread. This may free the UI thread up to do other things. If the execution is in the UI thread, then the UI thread will cooperatively schedule the code of the subVI with all of the other things it has to do, like drawing and servicing other VI Server requests.
As mentioned by others, the diagram that contains the node cannot complete. Other code within it might run in parallel if it is not dataflow dependent, but sooner or later, the code will sleep waiting for the subVI to complete and for the UI thread to copy the parameters back.The blocking behavior of the caller isn't affected by what threads the caller or subVI are executed in. It is an intentional synchronization feature. If you do not need to wait or do not want to wait for completion, then the invoke node with the Run method is what you want to look into.
You mentioned that you are also using ActiveX services. Just a caution, while it will work, using LV services via ActiveX within LV itself is not such a wise thing to do. So presumeably you are using ActiveX to affect other apps and servers and using the VI Server nodes to affect LV itself.
ActiveX services within LV support MTA if the server does. If MTA, any thread can go into the server and the server will provide its own protection, which can still block threads. If it is STA, then LV is responsible for the protection and it will do so by posting to the thread that loaded the server. In quite a few cases this turns out to be the UI thread.
So, I doubt that this background info is really that useful, so to go further, I think you will need to describe the exact task you are trying to carry out, what seems to be going wrong, what problems you see, alternatives you have tried, etc.
Greg McKaskle
11-15-2005 09:49 AM
11-15-2005 11:00 AM
11-15-2005 11:05 AM
11-15-2005 04:55 PM