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 3222
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: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
| |