DateTimes should only be checked against a datetime object or you can have issues.
Run you code in teh debugger to see what is being executed and where it is hanging. The form will freeze if you are stuck in a loop.
Timer Event Help
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.
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.
Re: Timer Event Help
You seem to be sitting in the timer tick. You cannot do this. Let the timer do the changes based on the time and not on linear code in the timer event.
Unfortunately thee is no way for me to guess at what you are trying to do and your code is not helpful.
Post the simplest PSF file you can that illustrates your issue.
Unfortunately thee is no way for me to guess at what you are trying to do and your code is not helpful.
Post the simplest PSF file you can that illustrates your issue.
Re: Timer Event Help
Yes, Jvierra. You are right, I'm sitting in the timer tick.
In this every 2 mins the label will flash...
In this every 2 mins the label will flash...
Re: Timer Event Help
OK based on what you are saying, I am using time to tell when they need to be executed. I provided a small example digitalClocktest.psf
Re: Timer Event Help
My first suggestion is to use an animated GIF to flash the message. This will eliminate one timer tasks. Next use time and not strings and make your decision based on the "Minutes" value of the time object which is an integer. It will be equal to 0 or 30 every 30 minutes. Run the timer at 1 minute ticks and check for those values.
This will simplify the logic and the code.
The hardest thing for those new to programming is to understand how to design a solution. This takes learning and experience. First learn all of teh available controls and how they are used then decide how to use those tools to accomplish a your tasks.
You approach can be made to work but stopping in a timer tick will only freeze the form.
This will simplify the logic and the code.
The hardest thing for those new to programming is to understand how to design a solution. This takes learning and experience. First learn all of teh available controls and how they are used then decide how to use those tools to accomplish a your tasks.
You approach can be made to work but stopping in a timer tick will only freeze the form.
Re: Timer Event Help
Thanks for your suggestions, Jvierra. Great ideas. I will make these changes in my project.
Im grateful for your time!!
Im grateful for your time!!
Re: Timer Event Help
Here is a simple example of some simplifications of the code:
Code: Select all
$timer1_Tick={
# set timer tick to 500ms so it detects by seconds.
$buttonclock.Text = [System.TimeZoneInfo]::ConvertTimeBySystemTimeZoneId([datetime]::Now, 'US Eastern Standard Time').ToString("h:mm:ss:tt")
if ([datetime]::Now.Minute -in (0,30) -and [datetime]::Now.Second -eq 0){
$timer1.Stop()
$labeltime.Visible = $true
$labeltime.Text = "Stay Active!!!"
$labeltime.BackColor = 'highlight'
$labeltime.ForeColor = 'yellow'
Start-Sleep -Milliseconds 255
$labeltime.BackColor = 'yellow'
$labeltime.ForeColor = 'highlight'
Start-Sleep -Milliseconds 255
$labeltime.BackColor = 'highlight'
$labeltime.ForeColor = 'yellow'
Start-Sleep -Milliseconds 255
$labeltime.Visible = $false
#Resume Clock
$timer1.Start()
}
}
Re: Timer Event Help
I ended up creating an animated gif to use. I stopped the clock and started a separate short timer for the animated image to play out. Thanks for your help.