LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Basic question

Hello,

i know now how to write simple CVI application with callback functions. My question is where i put my main code ( when there are not events ).
For example i write some application that all time draws something. Where i put code of drawing?
I need some function that executes all time that there are not events.
0 Kudos
Message 1 of 4
(3,176 Views)
Well, you have two options:

Option 1: Don't use RunUserInterface in main(). Instead write your own loop that does your normal code and calls ProcessSystemEvents() in a loop to monitor for events occurring.

Option 2: (RECOMMENDED) Use a Timer control. A timer control will generate events over and over at a regular interval in milliseconds that you can handle in a timer callback. This allows you to use the normal event processing and also run some other code ever 1 to N milliseconds.

Hope that helps,

Chris Matthews
National Instruments
Message 2 of 4
(3,176 Views)
Thanks, Chris.
I also readed in help that there is "event" EVENT_IDLE.
If i understand, i can receive this message as callback function if there is not event and to put there my code. How can i enable this "event"?
0 Kudos
Message 3 of 4
(3,176 Views)
No, you shouldn't use the EVENT_IDLE. That was provided before we had timer controls in CVI. As noted in the help, you should use timer controls instead of the obsolete EVENT_IDLE. Below is an excerpt from the CVI help:

Description: Idle events are sent to the main callback function on a regular basis, as long as LabWindows/CVI processes events. You can set the rate at which idle events occur using SetIdleEventRate. This event is now obsolete; it is recommended that you user timer controls.

Chris
0 Kudos
Message 4 of 4
(3,176 Views)