LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Slow menu response

I don't normally use menu bars in my applications but the one I am writing now has a need for a simple one. I created the menu bar in the UI editor and added it to the panel I need it on. It's all pretty straightforward and simple and it works except for one very annoying problem.

The first time I try to click the main menu item, it displays the child items right away but I can't select one for 10 or 15 seconds. All subsequent times I select it, it responds right away.

I am at a loss to understand what is going on here. Has anyone seen such behavior before?

I am using CVI 7.1 on WinXP SP2.

Any help would be appreciated.
Martin Fredrickson
Test Engineer

Northrop Grumman
Advanced Systems and Products
San Diego, CA 92128
0 Kudos
Message 1 of 8
(4,146 Views)
More information...

I tried moving my child menu items up to the top menu level, it still takes a long time for the menu to respond.

Don't see why this should make any difference at all but I writing this application as a multi-threaded program. I do UI stuff in the main thread, data logging in a second thread and the actual test control and acquisition code in a third thread.
Martin Fredrickson
Test Engineer

Northrop Grumman
Advanced Systems and Products
San Diego, CA 92128
0 Kudos
Message 2 of 8
(4,143 Views)
Hmmm, thats weird. I have not heard of this before.

Do you have a sample project that I can use to replicate this?

Thanks
Bilal Durrani
NI
0 Kudos
Message 3 of 8
(4,134 Views)
I do but it is not something I want to post to the forum. Is there an e-mail address I can send it to?
Martin Fredrickson
Test Engineer

Northrop Grumman
Advanced Systems and Products
San Diego, CA 92128
0 Kudos
Message 4 of 8
(4,129 Views)
I suggest emailing into support from here. This way, you can avoid posting code on the forum.

Thanks
Bilal Durrani
NI
0 Kudos
Message 5 of 8
(4,109 Views)
Thanks Bilal but I have decided to do away with the menubar and use buttons instead.

Solved the problem for me for now. If I need to use a menubar again and see the same problem, I will take the time to look into it further. Right now it is working and I don't have the time to chase after the issue.
Martin Fredrickson
Test Engineer

Northrop Grumman
Advanced Systems and Products
San Diego, CA 92128
0 Kudos
Message 6 of 8
(4,096 Views)
I am seeing this same kind of occurance in a project that I am now working on.  I know that the previous post is over a year old but was wondering if a solution had been found in the mean time.  I too am using multiple threads in my program.  A maximum of three can be running at one time but only two can possibly be running at the point that the slow response happens.  Just as MJF stated, the display of the child items is instantaneous but then it takes 10 or so seconds before a child item becomes highlighted to click on.  It also only happens the first time the menu bar is used.  As far as the two threads that are running when the menu bar is slow, one controls the UI and the other is in a while loop constantly checking a message queue for new messages to send out to the system hardware.  I am using CVI 8.0 and the program is running on a Windows XP system with SP2.
0 Kudos
Message 7 of 8
(3,958 Views)
You're right. I was able to reproduce this very large delay whenever I use a menu in a multithreaded application, if there are threads in the application that are not processing events, nor sleeping, at the time the menu is operated the first time.

I debugged the problem and tracked it down to a call that CVI makes to the multimedia SDK in order to play a system sound that is associated in the OS with opening a menu. Even if in most cases, there is no sound association.
The problem seems to happen because multiple DLLs are loaded at that time, and in the process of loading those DLLs, Windows need to send several messages to each thread in the system. If a thread is essentially blocked from responding to messages, this slows down the process considerably.

I realize that this is definitely a problem, and the next version of CVI should hav a fix for this, somehow. In the meanwhile, if you are able to put some code in your secondary thread to sleep periodically (the SDK function Sleep), or process events periodically (the CVI function ProcessSystemEvents) that should improve the response a fair amount.

Luis
NI
Message 8 of 8
(3,954 Views)