09-19-2006 09:10 AM
{if (quitFlag) CallCtrlCallback (QuitCallback)ProcessSystemEvents();Delay (????);}
09-19-2006 09:23 AM
Delay() is a busy wait function, which will therefore leave very little processing time for other threads. Look at using the SDK Sleep() function instead, which consumes virtually no CPU time.
JR
09-19-2006 09:35 AM
09-19-2006 10:14 AM
09-19-2006 10:34 AM
Make sure that windows.h is the first header file called, it will cause problems if you include it after other cvi header files.
09-19-2006
12:15 PM
- last edited on
11-06-2025
03:57 PM
by
Content Cleaner
This example also provides an older but very simple method to implement event processing in CVI without RunUserInterface()
http://sine.ni.com/apps/we/niepd_web_display.display_epd4?p_guid=B45EACE3DBA956A4E034080020E74861&p_node=DZ52172&p_source=external
09-19-2006 12:22 PM
09-19-2006 12:58 PM
09-19-2006
01:14 PM
- last edited on
11-06-2025
03:58 PM
by
Content Cleaner
Using Sleep() or SleepEx() is painless, if you have any trouble let us know.
Delay() blocks events in the thread you are in. It does not block other threads on an XP system. It does seem to consume much of the time slice the thread is allocated in. Which you use will depend on how efficient you really need to be to get the performance you need.
>>Sleep() works fine, but won't react to any callbacks.
You can use the SDK function MsgWaitForMultipleObjectsEx() which allows your thread to sleep but to be awakened by some types of events.
The methods described above of implementing a headless system with XP etc work just fine. Just for completeness here is another option, LabWindows/CVI Realtime. Embedded and headless systems are very much the target for this OS.
Message Edited by mvr on 09-19-2006 01:14 PM
09-19-2006 01:19 PM
NI has told me directly that Delay() is not a busy wait, though you can't tell how they implemented it. I think another NI guy claimed it calls ProcessSystemEvents() too - but if it does, that's undocumented as well. You could code a long delay and look at the app with task manager to see if it was busy waiting or not. I think it isn't - that would be extraordinarily poor form. I've asked about delay() several times in the past. It's great fun getting different answers 😉
I use a sleep call with the delay broken up into chunks that actually sleep(), and I process system events in between sleep() calls. This avoids a busy wait and keeps the gui responsive. Win32 SDK has a form of the sleep command that processes windows messages to provide the same sort of functionality. But the native windows messages are trapped by CVI normally and NI uses its own event model which of course is different.
NI wants the source to run on WIn32 as well as Unix/Linux, and the Delay() call provides portability. But if you're going to only run on Win32 platforms, I say go ahead and Sleep() instead.
I never got a T shirt but I did get a cute triangular metallic PAS 9 program pin - better than a tee or a coffee cup I say. What I really wanted to do was to go out to the equator with them on the launch platform or the command ship but they wouldn't take me along 😞
Menchar