SQLScholar
Programmer
Hey all,
I have this code:
Now.... If the action is running already, i dont want it to run again. So getcomputers looks something like this
Now unfortunately what seems to happpen is if the thread gets called while the thread is still running, it never runs the thread again.
How can i stop this happening? Effectively what i need is it to be able to run every X mins but if its already running then to not run. Or even something that only starts to trigger when its completed?
Any ideas? TIA
Dan
----------------------------------------
Be who you are and say what you feel, because those who mind don't matter and those who matter don't mind - Dr. Seuss
Computer Science is no more about computers than astronomy is about telescopes - EW Dijkstra
----------------------------------------
I have this code:
Code:
Public Class NetworkAudit
Dim Computername As String
Dim running As Boolean
Dim SQLConn As New ADODB.Connection
Protected Overrides Sub OnStart(ByVal args() As String)
' Add code here to start your service. This method should set things
' in motion so your service can do its work.
Const iTIME_INTERVAL As Integer = 60000 ' 60 seconds.
Dim oTimer As System.Threading.Timer
System.IO.File.AppendAllText("C:\AuthorLog.txt", "AuthorLogService has been started at " & Now.ToString() & vbCr)
System.Threading.Thread.Sleep(20000)
Dim tDelegate As Threading.TimerCallback = AddressOf EventAction
oTimer = New System.Threading.Timer(tDelegate, Me, 0, iTIME_INTERVAL)
End Sub
Public Sub EventAction(ByVal sender As Object)
System.IO.File.AppendAllText("C:\AuthorLog.txt", "AuthorLogService fires EventAction at " & Now.ToString() & vbCr)
Call GetComputerInfo()
End Sub
Now.... If the action is running already, i dont want it to run again. So getcomputers looks something like this
Code:
public sub getcomputers()
If running = true then exit sub
running = true
....OTHER CODE.......
Running = FALSE
end sub
Now unfortunately what seems to happpen is if the thread gets called while the thread is still running, it never runs the thread again.
How can i stop this happening? Effectively what i need is it to be able to run every X mins but if its already running then to not run. Or even something that only starts to trigger when its completed?
Any ideas? TIA
Dan
----------------------------------------
Be who you are and say what you feel, because those who mind don't matter and those who matter don't mind - Dr. Seuss
Computer Science is no more about computers than astronomy is about telescopes - EW Dijkstra
----------------------------------------