Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. stopping system .threading.timer

stopping system .threading.timer

Scheduled Pinned Locked Moved Visual Basic
helpquestion
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • E Offline
    E Offline
    Ebube
    wrote on last edited by
    #1

    assuming arrival method is still executing after say 40s seconds . how can i prevent the service from calling another instance pf arrival method Public Class intestService Protected Overrides Sub OnStart(ByVal args() As String) Dim tDelegate As Threading.TimerCallback = AddressOf Arrival oTimer = New System.Threading.Timer(tDelegate, Me, 10, 40) End Sub Public Sub Arrival(ByVal sender As Object) 'File.AppendAllText("C:\test4.txt", "AuthorLogService fires arrival at " & Now.ToString()) Try ' Catch ex As Exception log.WriteEntry(ex.Message, EventLogEntryType.Error) End Try End Sub Protected Overrides Sub OnStop() ' Add code here to perform any tear-down necessary to stop your service. End Sub End Class

    J 1 Reply Last reply
    0
    • E Ebube

      assuming arrival method is still executing after say 40s seconds . how can i prevent the service from calling another instance pf arrival method Public Class intestService Protected Overrides Sub OnStart(ByVal args() As String) Dim tDelegate As Threading.TimerCallback = AddressOf Arrival oTimer = New System.Threading.Timer(tDelegate, Me, 10, 40) End Sub Public Sub Arrival(ByVal sender As Object) 'File.AppendAllText("C:\test4.txt", "AuthorLogService fires arrival at " & Now.ToString()) Try ' Catch ex As Exception log.WriteEntry(ex.Message, EventLogEntryType.Error) End Try End Sub Protected Overrides Sub OnStop() ' Add code here to perform any tear-down necessary to stop your service. End Sub End Class

      J Offline
      J Offline
      Johan Hakkesteegt
      wrote on last edited by
      #2

      Dim TimerThreadIsRunning As Boolean Set it to true when you start your thread, and back to false at the end of Arrival method. Start the thread only if the boolean is false.

      My advice is free, and you may get what you paid for.

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups