08-25-2005 12:28 AM
08-25-2005 12:36 AM - edited 08-25-2005 12:36 AM
Message Edited by EVS on 08-25-2005 09:38 AM
09-19-2005 12:52 PM
09-19-2005 01:10 PM - edited 09-19-2005 01:10 PM

Of course in a more general case, you would add another button or local variable and use logical OR between them so the loop can also be stopped either with the timer or manually as needed.
Message Edited by altenbach on 09-19-2005 11:13 AM
09-19-2005 01:14 PM
09-19-2005 01:17 PM
09-19-2005 02:35 PM
09-19-2005 04:40 PM
If you don't use a wait, the loops will spin as fast as they can, millions of times/second gobbling up all CPU. A small wait will give other processes running on your computer a better chance to get a slice of the pie.
Monitor your CPU usage. Run a tiny VI with one while loop. The CPU will be pegged at 100%. Now add a few ms wait statement and the CPU usage will be near 0%, insignificant. A typical multitasking computer has many processes running. You migh browse the web, edit a document, and so on. Imagine each program would be written to cosume all available CPU. Your computer would be unusable!
The main user interface loop should always use a wait statement of e.g. hundred milliseconds. There is no need to check for user input 1000x per second, because it does not happen that often. It does also not make sense to recalculate the same old inputs over and over again as fast as you can. Often, the user interface loop can use an event structure so thing only get recalculated when needed, but then without any delay.
(Of course there is a use for loops without any wait statements, for example a small FOR loops that does some quick computation on arrays.)