LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Concurrent ActiveX Events from COM Server hang LabVIEW

Hi All,

 

I am to develop a LV library for a Windows application which implements a COM server. A .tlb file is provided in order to access via ActiveX methods and properties of the application. I open a reference to it with "Automation Open", then use the provided methods to e.g. read/write variables.

 

There is also a possibility of registering events, specifically a ValueChanged event for each variable. I can use "Reg Event Callback" to monitor one variable, when the value changes a Callback VI is called. The problem comes when I try to register two or more events, in this case LabVIEW hangs invariably as soon as the VI starts running (GUI not responding, no CPU load, need to kill process). It is not important what the Callback actually does, LV hangs even if the Callback does nothing at all.

 

Attached is a screenshot of the part where I register the events. One event is registered for each variable (2 variables here) in the for loop. After that the VI simply waits, at the end (but that is never reached...) events get unregistered, etc.

 

What I am trying to figure out is if the problem is in the application library ("tlb file") or rather I am doing something wrong in LV, while registering these events. Is it generally speaking possible to register several events which may and will happen in parallel? I would think so... I have already tried that e.g. with Excel. I also tried several different "layouts" as well as running the whole thing on a different machine and with a different version of LV (here I am using LV2011 SP1).

 

Any hint would be appreaciated. Thanks.

0 Kudos
Message 1 of 11
(3,536 Views)

@mm22 wrote:

 

What I am trying to figure out is if the problem is in the application library ("tlb file") or rather I am doing something wrong in LV, while registering these events. Is it generally speaking possible to register several events which may and will happen in parallel? I would think so... I have already tried that e.g. with Excel. I also tried several different "layouts" as well as running the whole thing on a different machine and with a different version of LV (here I am using LV2011 SP1).

 


I mean LV2010 SP1 here. Anyone has experience using ActiveX Events with a COM server? Thanks.

0 Kudos
Message 2 of 11
(3,507 Views)

Hi mm22,

 

Have you tried running Highlight Execution to see exactly where your code is hanging up?  Knowing exactly where the hangup is could help us determine why your code is not functioning properly.  Thanks!

Taylor G.
Product Support Engineer
National Instruments
www.ni.com/support
0 Kudos
Message 3 of 11
(3,501 Views)

Hi Taylor,

 

Thanks for your reply. The hangup occurs exactly the moment the second event is registered (the Reg Event Callback node, the second time my For loop executes). I should add that this does not happen all the time, but most of the times (i.e. > 90%). There are times when the program runs just fine after the registration process has been accomplished and the VI enters the "waiting" loop, detecting and reporting events correctly. Then when I stop the VI and run it again, it is 99.9% sure the VI will hang. I still haven't been able to find exactly when that happens (e.g. tried to stop/restart the COM server and/or the application between runs, restarting the computer, also which variables are monitored does not seem to matter).

 

If the COM client is implemented using another platform instead of LabVIEW the problem does not seem to appear.

 

Regards,

Marco

0 Kudos
Message 4 of 11
(3,495 Views)

Hi mm22,

 

Have you tried this by simply duplicating the code and removing your for loop?  This would not be ideal for many events, but it would be interesting to see if you get the same error when trying to register multiple events.  Thanks!

Taylor G.
Product Support Engineer
National Instruments
www.ni.com/support
0 Kudos
Message 5 of 11
(3,471 Views)

@Taylor G wrote:

Have you tried this by simply duplicating the code and removing your for loop?  This would not be ideal for many events, but it would be interesting to see if you get the same error when trying to register multiple events.  Thanks!


Yes I have tried that, as well as splitting the Event registration across VIs (i.e. one event only gets registered in each VI, multiple VIs run at the same time). No matter how multiple events get registered the program hangs (no error, just GUI lockup) as soon as the second event is registered.

 

A possibly unrelated error message I got (but only once) was a LV Fatal Error with reference to eventoracle.cpp, this only happened once and not necessarily when registering the second event.

0 Kudos
Message 6 of 11
(3,462 Views)

Hi mm22,

 

When you saw the LV Fatal Error, did this crash LabVIEW?  Also, I have a few other questions.  When you tried this with Excel, for instance, did you have the same issue?  Also, did you have any success running it on other machines or with any other "layouts" that you attempted?  Thanks!

Taylor G.
Product Support Engineer
National Instruments
www.ni.com/support
0 Kudos
Message 7 of 11
(3,445 Views)

@Taylor G wrote:

Hi mm22,

 

When you saw the LV Fatal Error, did this crash LabVIEW?  Also, I have a few other questions.  When you tried this with Excel, for instance, did you have the same issue?  Also, did you have any success running it on other machines or with any other "layouts" that you attempted?  Thanks!


Hi Taylor,

 

Yes it did crash after the fatal error, but this only happened once. Normally I see no error and LV hangs, I doubt there is a relation between the two. There are cases when the program runs correctly for some time, but these are rare occurrences and not easily reproducible (not by restarting server/computer, ...).

 

I tried in Excel, modified the given example to register multiple events, no problems there. Yes, all layouts I could think of, on different machines and with different versions of LabVIEW.

 

I think the problem might ultimately lie in the COM server and/or the application. As a general question, is it recommended to register multiple events (in my case could be 20-30 events)? Or would it be better to just poll for changes in the variables to monitor? As most variables rarely change I thought it would make sense to use events rather than polling, but I am not sure how much overhead this would bring as opposed to polling.

 

Thanks again.

0 Kudos
Message 8 of 11
(3,436 Views)

Hi Marco,

 

In regard to your question about registering events vs. polling for changes in the variables, registering events will likely be the better choice. Polling will only be able to check once for every iteration of the loop and will take up more resources than using events, which will immediately detect the value change.

 

In looking at the Register Event Callback Help, it shows that the callback VI must be reentrant. This will allow for the VI to be called multiple times. You may want to check the Knowledge Base article, Differences Between Reentrant VIs (Preallocate), Reentrant VIs (Share Clones), VI Templates, and Dyn..., for a discussion of reentrant VIs. Go to (File >>VI Properties >>Execution) to check if the VI is reentrant or not (VIs are typically non-reentrant by default).

 

I hope that helps!

 

 

Matt
NI Community Team
National Instruments
0 Kudos
Message 9 of 11
(3,408 Views)

Hi Matt,

 

Yes my callback VIs are always reentrant. They are created that way by LV anyway, when right-clicking on the event registration node. What I put in the callback (even nothing) is irrelevant to the outcome (hang-up occurs as soon as the second event is registered).

 

Do you have any other idea of where the problem could be? The strange thing is, events work for the application when we connect through a different application (e.g. Excel/VB), only with LV there is a hang-up. On the other hand LV ActiveX events work well on the same machine (or at least do no lead to a hang-up) with all "default" examples (like Excel, IE, ...).

 

Thanks and regards,

Marco

0 Kudos
Message 10 of 11
(3,399 Views)