One way to minimize cpu usage is to make sure that the CVI Sleep policy is set to sleep more. You can do this by going to the project window, Options >> Environment, and selecting sleep more from the top pull down menu.
When you're inside RunUserInterface, the CVI run-time engine is in a continuous loop, peeking for system events. CVI needs to process and dispatch these events, in order to maintain its internal state valid. Every time through this loop, we sleep, in accordance with the user's sleep policy. This loop is what causes the CPU time to be high, although the more you sleep the lower the time usage is. Also, the more events we receive, the higher the CPU time (hence the increase when the mouse moves).
Another thing you could do is replace RunUser
Interface() with a while loop that run ProcessSystemEvents() and has a sleep set for a certain time period, something like the following
#include
// for the Sleep function
int gQuit = 0; // global flag that should be set when calling QuitUserInterface
while (!gQuit) {
ProcessSystemEvents ( );
Sleep (10);
}
This should bring the CPU usage down as well.
I hope this helps
Bilal Durrani
NI
Bilal Durrani
NI