title: Trying to change a timer once a button is pressed
body: <p>I have a check going every 60 seconds, if the alarm is true it will open form2 play a song etc.</p>
  
  <p>but the button on form2 should set the waittimer = 180000 which should make the next check occur half an half an hour later. </p>
  
  <p>I'm not used to using timers, what am I doing wrong?</p>
  
  <pre><code>Public Class Form1
  Public Property waittimer As Integer
  Public Property playsong As Boolean = True
  Private WithEvents Tmr As New Timer
  
  Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
      If (Process.GetProcessesByName(Process.GetCurrentProcess.ProcessName).Length &gt; 1) Then
          Application.Exit()
      End If
      Tmr.Enabled = False
      Tmr.Interval = TimeSpan.FromSeconds(60).TotalMilliseconds
      BackgroundWorker1.RunWorkerAsync()
  End Sub
  
  Private Sub NotifyIcon1_MouseDoubleClick(sender As Object, e As MouseEventArgs) Handles NotifyIcon1.MouseDoubleClick
      playsong = False
      Try
  
  
          ' Create a request for the URL. 
          Dim request As WebRequest = _
            WebRequest.Create("http://example.com/example.aspx")
          ' If required by the server, set the credentials.
          request.Credentials = CredentialCache.DefaultCredentials
          ' Get the response.
          Dim response As WebResponse = request.GetResponse()
          ' Display the status.
          Console.WriteLine(CType(response, HttpWebResponse).StatusDescription)
          ' Get the stream containing content returned by the server.
          Dim dataStream As Stream = response.GetResponseStream()
          ' Open the stream using a StreamReader for easy access.
          Dim reader As New StreamReader(dataStream)
          ' Read the content.
          Dim responseFromServer As String = reader.ReadToEnd()
          ' Display the content.
          Console.WriteLine(responseFromServer)
          ' Clean up the streams and the response.
          reader.Close()
          response.Close()
  
          Dim responseArray() As String
          responseArray = Split(responseFromServer, "|")
  
          Dim D As New Data
          D.maxcalls = responseArray(0)
          D.cph = responseArray(1)
          D.mht = responseArray(2)
          D.alarm = responseArray(3)
          Form2.startsong(D)
      Catch ex As Exception
  
      End Try
      playsong = True
  End Sub
  
  Private Sub ExitToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles ExitToolStripMenuItem.Click
      Application.Exit()
      End
  End Sub
  
  Private Sub BackgroundWorker1_DoWork(sender As Object, e As System.ComponentModel.DoWorkEventArgs) Handles BackgroundWorker1.DoWork
      Try
          If waittimer = 180000 Then
              Tmr.Interval = waittimer
              Tmr.Start()
              waittimer = 60000
          Else
              waittimer = 60000
          End If
  
          ' Create a request for the URL. 
          Dim request As WebRequest = _
            WebRequest.Create("http://example.com/example.aspx")
          ' If required by the server, set the credentials.
          request.Credentials = CredentialCache.DefaultCredentials
          ' Get the response.
          Dim response As WebResponse = request.GetResponse()
          ' Display the status.
          Console.WriteLine(CType(response, HttpWebResponse).StatusDescription)
          ' Get the stream containing content returned by the server.
          Dim dataStream As Stream = response.GetResponseStream()
          ' Open the stream using a StreamReader for easy access.
          Dim reader As New StreamReader(dataStream)
          ' Read the content.
          Dim responseFromServer As String = reader.ReadToEnd()
          ' Display the content.
          Console.WriteLine(responseFromServer)
          ' Clean up the streams and the response.
          reader.Close()
          response.Close()
  
          Dim responseArray() As String
          responseArray = Split(responseFromServer, "|")
  
          Dim D As New Data
          D.maxcalls = responseArray(0)
          D.cph = responseArray(1)
          D.mht = responseArray(2)
          D.alarm = responseArray(3)
          D.forcealarm = False
          e.Result = D
      Catch ex As Exception
          Dim D As New Data
          D.maxcalls = 404
          D.cph = 404
          D.mht = 404
          D.alarm = True
          D.forcealarm = True
          e.Result = D
      End Try
  
      Tmr.Interval = waittimer
  End Sub
  
  Private Sub BackgroundWorker1_RunWorkerCompleted(sender As Object, e As System.ComponentModel.RunWorkerCompletedEventArgs) Handles BackgroundWorker1.RunWorkerCompleted
      If Not IsNothing(e.Result) Then
          Dim strtime As String
          Dim englandtime = System.TimeZoneInfo.ConvertTime(Now, TimeZoneInfo.FindSystemTimeZoneById("UTC"))
          strtime = DatePart(Microsoft.VisualBasic.DateInterval.Hour, englandtime) &amp; DatePart(Microsoft.VisualBasic.DateInterval.Minute, englandtime)
  
          Dim D As Data = DirectCast(e.Result, Data)
          If D.forcealarm = True Then
              Form2.startsong(D)
          End If
          If D.alarm Then
              If strtime &lt; 730 And strtime &gt; 0 Then
  
              Else
                  Form2.startsong(D)
              End If
          End If
      End If
      Tmr.Start()
  End Sub
  
  Private Sub Tmr_Tick(sender As Object, e As System.EventArgs) Handles Tmr.Tick
      Tmr.Stop()
      BackgroundWorker1.RunWorkerAsync()
  End Sub
  
  End Class
  
  Public Class Data
  Public Property maxcalls As Integer
  Public Property cph As Integer
  Public Property mht As Integer
  Public Property alarm As Boolean
  Public Property forcealarm As Boolean
  End Class
  </code></pre>
  
  <p>Form2</p>
  
  <pre><code>Public Class Form2
  Public audio As New AudioFile(My.Application.Info.DirectoryPath &amp; "\Help.mp3")
  Public Sub startsong(ByVal D As Data)
      Me.Show()
      MHTvalue.Text = D.mht.ToString
      Maxcallsvalue.Text = D.maxcalls
      CPHvalue.Text = D.cph
      If Form1.playsong = True Then
          audio.Play()
      End If
  
  End Sub
  
  Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
      ' Me.Close()
      audio.Stop()
      Form1.waittimer = 180000
  End Sub
  
  Private Sub Form2_Closing(sender As Object, e As EventArgs) Handles MyBase.Load
      audio.Stop()
      Form1.waittimer = 180000
  End Sub
  
  Private Sub Form2_Minimize(sender As Object, e As EventArgs) Handles MyBase.Load
      audio.Stop()
      Form1.waittimer = 180000
  End Sub
  </code></pre>