dalsym
asked on
VB.NET Stopwatch devouring Processor - alternatives?
Visual Studio 2005 Pro
-------------------------- ---------- -------
Dim objTimer As Stopwatch = New Stopwatch
'Interval in timecode (00:00:00.0000000) at which the monitor will query server for a response. Default: 5 minutes = 00:05:00.0000000
Dim strTimer_Interval As String
Sub Execute_Timer()
strTimer_Interval = My.Settings.strTimer_Inter val
objTimer.Start()
While objTimer.Elapsed.ToString < strTimer_Interval
End While
objTimer.Reset()
Run_Program()
End Sub
-------------------------- ---------- -------
The above code is used as part of a monitoring program I have written. The idea is that the Run_Program function which contains all of the main processing functions should only occur every 15 minutes (or whatever value you enter in the config file).
After Run_Program(), I call the Execute_Timer() function shown above. The idea is that nothing is supposed to happen for the next 15 minutes. After 15 minutes, Run_Program() again, etc...
The trouble is the WHILE statement is jacking my Processor to 100% utlization. Which, *duh*, makes sense now that I think about it, but I need an alternative solution (ideally one that can coded into the application (example, not looking for cron or Scheduled Task solutions) that doesn't burn my clock up!
Thanks!
--------------------------
Dim objTimer As Stopwatch = New Stopwatch
'Interval in timecode (00:00:00.0000000) at which the monitor will query server for a response. Default: 5 minutes = 00:05:00.0000000
Dim strTimer_Interval As String
Sub Execute_Timer()
strTimer_Interval = My.Settings.strTimer_Inter
objTimer.Start()
While objTimer.Elapsed.ToString < strTimer_Interval
End While
objTimer.Reset()
Run_Program()
End Sub
--------------------------
The above code is used as part of a monitoring program I have written. The idea is that the Run_Program function which contains all of the main processing functions should only occur every 15 minutes (or whatever value you enter in the config file).
After Run_Program(), I call the Execute_Timer() function shown above. The idea is that nothing is supposed to happen for the next 15 minutes. After 15 minutes, Run_Program() again, etc...
The trouble is the WHILE statement is jacking my Processor to 100% utlization. Which, *duh*, makes sense now that I think about it, but I need an alternative solution (ideally one that can coded into the application (example, not looking for cron or Scheduled Task solutions) that doesn't burn my clock up!
Thanks!
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
You're welcome!
ASKER
thanks!