Ask questions about creating Graphical User Interfaces (GUI) in PowerShell and using WinForms controls.
Forum rules Do not post any licensing information in this forum.
Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
This topic is 3 years and 9 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
I'm attempting to create an app which displays a digital time clock. - I'm using a timer named timer1. No problem.. At 30 min and top of the hour I want the clock to stop/pause or even turn off..and Display a label.
Not the button. The code that the button executes goes in the timer tick.
To detect the interval you want to not use the ticks but check the system clock modulus 30. This will cause a detection at each 30 minute interval. The code has to set a flag when the interval is detected then clear the flag after the interval is complete. This prevents multiple triggers if teh tick occurs more that once when "minutes" is equal to 0 or 30. THe issue is to always detect teh boundary conditions that occur but time is an issue. Time does not have an absolute boundary. Clock time runs in segments depending on resolution.
Another way to do this is to use a countdown time that events in 30 minutes. Execute your code then rearm the timer and it will only tick again in 30 minutes. The problem with this approach is the countdown timers insert skew. They can be used but require occasional correction. Using the system clock is easier and more reliable.
I apologize, Im having a tough time with this.
I'm looking for the trigger to happen at specific times. 7, 7:30, 8, 8:30..
Will the clock modulus work like this?
Also, the code of the button is in the timer.. it just shows the time
When I was checking with the IF statement I think I was checking a datetime against a string. So I made them both strings and now it sees the trigger.
My only hiccup now is sometimes the label flash portion will freeze/stall?...Which I don't understand fully because I stop the timer and the labels flashing is a whole 5 seconds. Im not sure how to make it more efficient and reliable?..
This topic is 3 years and 9 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.