Bruce,
Any reason you are doing this with a timer rather then let a
System.IO.FileSystemWatcher notify you when the file changes?
What I do is set Timer.AutoReset to False, so the event does not
automatically fire. Then at the end of the Timer.Elapsed event handler I set
a new interval & set Timer.Enabled to True. Setting the interval should not
be needed, I do it as I have varying intervals that are based on other
factors...
> Dim t As New System.Timers.Timer(12000) ' 1000 = 1 Second
> This in turns fires up my sub called "TimerFired" every 2 minutes...
Are you certain? It appears that your event will fire every 12 seconds.
Normally what I do is use a TimeSpan to calculate the interval.
Something like:
Dim ts As TimeSpan = TimeSpan.FromMinutes(2)
Dim t As New System.Timers.Timer(ts.TotalMilliseconds)
Or more succinctly:
Dim t As New
System.Timers.Timer(TimeSpan.FromMinutes(2).TotalMilliseconds)
Hope this helps
Jay
"Mr. B" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> My current app has a timer that I kick ON in my Form1_Load as follows:
>
> ' Set Up the Timer Function
> Dim t As New System.Timers.Timer(12000) ' 1000 = 1 Second
> t.Enabled = True ' False to Turn OFF
> AddHandler t.Elapsed, AddressOf TimerFired
>
> This in turns fires up my sub called "TimerFired" every 2 minutes...
>
> In this sub, I check a file for a change in the date/time and if I find a
> difference (ie newer file date), I then continue on with the sub and does
> some
> updating. Otherwise I end the sub and the timer continues on with it's
> periodical check.
>
> What I want to do is to "Stop" the Timer event 'when' the sub does it's
> updating... then fire it back up when the 'stuff' finishes.
>
> I've tried a few things such as:
>
> Timer1.Enabled = False
>
> in my Sub... but that doesn't work...
>
> Any ideas out there?
>
> Regards,
>
> Bruce
|