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 6 3234
Mr B
I do some programming in java, c/c++ etc I have not done any
programming in VB yet, but I would assume the timer would execute in a
seperate thread than the main program is their a way to block/lock or suspend
the thread while processing the file?? can this be done in VB I don't know
Just a thought.
Cheers
Mitchell
"Mr. B" wrote: 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
Mr B
I do some programming in java, c/c++ etc I have not done any
programming in VB yet, but I would assume the timer would execute in a
seperate thread than the main program is their a way to block/lock or suspend
the thread while processing the file?? can this be done in VB I don't know
Just a thought.
Cheers
Mitchell
"Mr. B" wrote: 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
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).TotalM illiseconds)
Hope this helps
Jay
"Mr. B" <Us**@NoWhere.com> wrote in message
news:8f********************************@4ax.com... 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
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).TotalM illiseconds)
Hope this helps
Jay
"Mr. B" <Us**@NoWhere.com> wrote in message
news:8f********************************@4ax.com... 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
Define "doesn't work". That is precisely how you turn the (12-second) timer
off. Do you get an error?
Jeff
"Mr. B" <Us**@NoWhere.com> wrote in message
news:8f********************************@4ax.com... 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
Define "doesn't work". That is precisely how you turn the (12-second) timer
off. Do you get an error?
Jeff
"Mr. B" <Us**@NoWhere.com> wrote in message
news:8f********************************@4ax.com... 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 This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: curious |
last post by:
I am new to VB.NET and I need help in using timer control. Here is
the scenario. I have 3 labels (label 1, label2, label 3), and a start
button, all vertically aligned on the form.
Using a...
|
by: William Bub |
last post by:
Is there an accurate way to create a "stopwatch" good to 1/10 of a second?
I'm not sure if I should use the timer control, or some way to access the
computer timer. I found the following site...
|
by: David |
last post by:
Hi There!
I'm using Timer control to record how long my application perform certain
tasks.
However, apparently Timer control is not doing its' job (i.e. Not firing
Tick event) while my...
|
by: Mr. B |
last post by:
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...
|
by: tom |
last post by:
Hey All-
For those of you having troubles with listviews appearing in the
wrong position when on a tab control, we've come up w/one other
workaround that may be useful.
When you move to the...
| |
by: Z D |
last post by:
Hello,
I've created a winform user control that, at some point in the default
constructor, looks for a specifc file.
When I try to load the user control to my winform's form during design time...
|
by: Steve |
last post by:
I am working on a emulator and need to have time based events. I've tried
to use the timer control and discovered that it runs waaaaaaay slow. I set
the tick frequency to 1, then in the tick...
|
by: Sudharsan |
last post by:
Hi
I have developed a Windows Control Library in VC.NET
The component will play back video files and this component is used in C#
applications to display multiple videos simultaneously.
The...
|
by: Chris Dunaway |
last post by:
I have a main form with a "lock" button. When the lock button is
clicked, another form is shown using ShowDialog(this). The user must
enter their PIN on this form to close it and resume the main...
|
by: Steve |
last post by:
Hi All
I am using VB.net 2008 and use timer controls within my applications
Question
Does the code in a Timer control.tick event run on a different thread to the
main Application thread (UI...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The...
| |
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |