Disabling Timer

I am using the timer component to delay the execution of a vb script. Once that vb script
has been run, I then need the timer to be disabled automatically. Is this possible?

Actually I found another solution that is to use the time buffer.

Many thanks

You need to iterate through all the timers on the canvas and then find the one that is connected to your component:

Private Sub RunScript(ByVal reset As Boolean, ByVal max As Integer, ByRef A As Object) 
    If (reset) Then
      counter = 0
    End If
    counter += 1
    A = counter
    If (counter >= max) Then
      Dim ghdoc As GH_Document = owner.OnPingDocument()
      If (ghdoc Is Nothing) Then Return
      For Each docobj As IGH_DocumentObject In ghdoc.Objects
        Dim timer As Special.GH_Timer = TryCast(docobj, Special.GH_Timer)
        If (timer Is Nothing) Then Continue For
        If (timer.Targets.Contains(owner.InstanceGuid)) Then
          timer.Locked = True
        End If
    End If
  End Sub 

  '<Custom additional code> 
  Dim counter As Integer = 0

WT4.gh (13.8 KB)

1 Like

Thank you for your help.