[Webinar] Streamline your web hosting managementRegister Today


timing assistance

Posted on 2008-02-12
Medium Priority
Last Modified: 2010-04-23
Need some help with my logic here - just want to make sure I'm not overlooking anything...

I have a service that when it's first launched (or more precisely 10 seconds later), it begins testing for the presence of a file.
If the file exists, it begins the copy and extraction process, which takes about 10-15 minutes (the file will vary slightly on a daily basis, so this is a rough range).
If the file isn't there, the test occurs (setting the timer interval) every 10 minutes until it is there.

Sadly, the file is never created at the same point - it varies by an hour or two (or more - and possibly not at all).

Once the copy process is successful, I set the timer interval to 20 hours to await the next generation, at which point the timer is then set to 10 minutes until it's found again.

Lastly, if the timer tick ever occurs on a weekend day, I reset the interval to 24 hours and wait until the following business day to try again.

That said, I'd like some suggestions/corrections in case I've set this up incorrectly...here's the sub:
Shared Sub tmr_Tick(ByVal source As Object, ByVal e As Timers.ElapsedEventArgs)
  If blnCopyInProgress Then
    Exit Sub
    Select Case Today.DayOfWeek
      Case DayOfWeek.Saturday Or DayOfWeek.Sunday
      tmr.Interval = 86400000 'delay 24 hours
      Exit Sub
    Case Else
      'other logging code here
    End Select
  End If
  If tmr.Interval <> 600000 Then tmr.Interval = 600000
  If File.Exists(strSrcFile) Then
    tmr.Interval = 72000000 ' wait 20 hours before trying again
  End If
End Sub

Open in new window

Question by:sirbounty
LVL 34

Accepted Solution

Sancler earned 500 total points
ID: 20882784
Looks good to me - although, obviously ;-), not tested

LVL 48

Assisted Solution

by:Jorge Paulino
Jorge Paulino earned 500 total points
ID: 20883284
It seams Ok for me (except the copydata that we don't see it)

It's normally a good practice to stop the timer in the beggining of the rotine (enable = false) and enable it again in the end, but in here seams not critical.


PS: Also not tested
LVL 67

Author Comment

ID: 20883598
Haha - thanx guys.

Featured Post

Learn to develop an Android App

Want to increase your earning potential in 2018? Pad your resume with app building experience. Learn how with this hands-on course.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: Jorge
XML Literals are a great way to handle XML files and the community doesn’t use it as much as it should.  An XML Literal is like a String (http://msdn.microsoft.com/en-us/library/system.string.aspx) Literal, only instead of starting and ending with w…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
How to fix display issue, screen flickering issue when I plug in power cord to the machine. Before I start explaining the solution lets check out once the issue how it looks like after I connect the power cord. most of you also have faced this…
Get the source code for a fully functional Access application shell with several popular security features that Access VBA application developers desire, but find difficult or impossible to figure out how to code. You get the source code for managi…
Suggested Courses

640 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question