Timer

Hi,

i have problem with timer

  $timer1.Interval = 1000
    [datetime]$StartDate = (Get-Date)
    [datetime]$EndDate = (Get-Date).AddMinutes(1)
    $timer1.Start()
    $timer1.Add_Tick({
            If ($EndDate -le 0) 
            {
                $timer1.Stop()
                $MainForm.WindowState = 0
                $MainForm.StartPosition = 'CenterScreen'
                $MainForm.TopMost = $True
            } 
            Else 
            {
              # this is just for test
              Write-Host "booooo"
            }
            
        })

what i try to do, i have a form that i minimize, and after 10 min i want this form will pop up on the center of the screen

Thanks.

Hi Curtis,
Thank you for link

i try this

$TT = 600 #in seconds 
        #Add TotalTime to current time 
        $script:StartTime1 = (Get-Date).AddSeconds($TT) 
           
    $timer1_Tick={
      # countdown timer
      [TimeSpan]$span1 = $script:StartTime1 - (Get-Date)
      # Update the display
      $hours1 = "{0:00}" -f $span1.Hours
      $mins1 = "{0:00}" -f $span1.Minutes
      $secs1 = "{0:00}" -f $span1.Seconds
      $labelTime.Text = "{0}:{1}:{2}" -f $hours1, $mins1, $secs1
      
      $timer1.Start()
      if ($span1.TotalSeconds -le 0)
      {
            
            $timer1.Stop() 
            $MainForm.WindowState = 0
            $MainForm.StartPosition = 'CenterScreen'
            $MainForm.TopMost = $True             
       
      }
      else
      { Write-Host "booooom"}

but still not working

Please help

I try simple

$a = (Get-Date).AddSeconds(20)
$PopUp = $false
while($PopUp -ne $true)
{
    $b = Get-Date
    if($b -eq $a)
    {
        $c = new-object -comobject wscript.shell
        $d = $c.popup("done",0,"Test Message Box",1)
        $PopUp = $true
    }}

but its not working when i change this on winform
why?

Where are you registering the event handler as shown on the page in the provided link?