larryllix Posted December 23, 2013 Posted December 23, 2013 Scenario: If I have a lamp on and one programme will dim the device in say.. 5 minutes. Another programme is called and it decides to turn of the lamp in 10 minutes but leaves the dimming event active. Will both timers work? Will the latest timer cancel the previous timer? What will happen? Are timers dedicated to each device and only one can be running at any given point in time? or Are timers just freely allocated timers and control programme execution? If so, is there a quantity limit on timers running concurrently?
LeeG Posted December 23, 2013 Posted December 23, 2013 "Will both timers work?" Both Programs will run. The first program dims the device (to Off?) in 5 minutes. If the first program turns the lamp off the second program will send another Off after the program has run for 10 minutes. "Will the latest timer cancel the previous timer?" No, not with the information provided. "What will happen?" Both programs run to completion. "Are timers dedicated to each device and only one can be running at any given point in time? or Are timers just freely allocated timers and control programme execution? If so, is there a quantity limit on timers running concurrently?" There is no 'timer' type program. The programs perform as they have been coded. One could cancel the other if coded to do so. They may do nothing to each other as I have assumed with the previous answers.
marvel Posted December 23, 2013 Posted December 23, 2013 By "timer" I assume you're talking about a "wait." Waits control program execution only and have nothing to do with devices. You're just telling the program to sit there for a specified time before continuing on to the next statement. That wait will only be canceled if the "if" statement that led to the wait's execution becomes false. There is no process that takes the next action beyond the "wait" into consideration. Determining what will happen in your scenario is dependent on the "if" statements. Assuming both "if" statements remain true for the duration of both waits, then both waits will function simultaneously and command execution for each program will continue normally after that program's wait expires. To cancel a wait (and, thus, further execution of the program in question), you will need to do something to make the "if" statement for that program become false. Are timers just freely allocated timers and control programme execution? Yes. If so, is there a quantity limit on timers running concurrently? I don't know the answer to that question. Hope this helps!
larryllix Posted December 23, 2013 Author Posted December 23, 2013 Thank you. This clears up some confusion.
Recommended Posts