LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Dialog box locks up redrawing ring control in separate loop.

I created some code that uses 'user32.dll' to display a Windows dialog box.  For some reason and under certain conditions,  this dialog box locks up the front panel of redrawing a ring control.  The ring control is updated using property nodes in a Separate loop.

 

I attached a small test VI to demonstrate.  If you select 'Use Control Refnum' and click on the Windows Dialog 'Enable' button, then the ring will not draw until the dialog box is acknowledged.   The same issue does not occur with LabVIEW dialog boxes, the other button.  Plus if you update the control directly I have no problems with the custom windows dialog box.

 

It is probably something do with the Call Library Node, running under the UI thread.  

 

Could anyone give me a good explanation?

 

Thanks,

PH

 

 

0 Kudos
Message 1 of 6
(2,386 Views)

The windows dialog box may not play well with the event structure.  You might try incorporating the functionality of the lower loop into the upper loop using a timeout.  That way, all of the control behavior is captured in the event structure.

 

I couldn't replicate the issue on my machine.

>

"There is a God shaped vacuum in the heart of every man which cannot be filled by any created thing, but only by God, the Creator, made known through Jesus." - Blaise Pascal
0 Kudos
Message 2 of 6
(2,376 Views)

Also, there is a performance hit for assigning the ring control value by property node.

>

"There is a God shaped vacuum in the heart of every man which cannot be filled by any created thing, but only by God, the Creator, made known through Jesus." - Blaise Pascal
0 Kudos
Message 3 of 6
(2,374 Views)

The DLL call is configured to run in the UI thread. Any call to the property node also executes in the UI thread. Because the UI thread is in the middle of calling the function, it has to wait unti that's over before it can execute the property.

 

You could configure the DLL call to run in any thread, but that requires the function to be thread-safe, and I don't know if that specific function is. You could try searching MSDN to see if the documents thread safety of the Windows API functions.


___________________
Try to take over the world!
Message 4 of 6
(2,368 Views)

The Call Library Function is set to run in the UI Thread.  Therefore, no front panel updates can be performed while the function is running (ie, the dialog box is showing).


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 5 of 6
(2,365 Views)

Thank you.  Yes, that appears to be the solution.  I could change the function to MessageBoxA to run with 'Any thread' and it seems to work ok.  I couldn't find much on the thread safety of the user32.dll function with respect to the MessageBoxA function so honestly i have no idea if changing it to Any Thread would cause any adverse affects.

 

I will have to give it some more thought on the solution.  What I like about the windows message box is that you can easily specify the # of buttons, icons, default buttons, etc..   I will look around to see if anyone has developed a VI that could mimic the windows dialog box without the user32 dll issues.

 

Thanks,

 

PH

0 Kudos
Message 6 of 6
(2,351 Views)