473,796 Members | 2,720 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Timer Events

Max
This may be an elementary question but it's something I have not encountered
in about 10 years writing code in VB 5 / 6

I have a timer that using the API checks if there has been a change to one
of several watched directories in the file system, if there has been a
change a rather long running process is started.

The long running process loops through all files comparing the last modified
attributes on each to those in the database if there is a change the
database is updated.

Simple so far right ?

Just prior to the loop statement in that routine there is a DoEvents to keep
everything ticking along, however something interesting happens.

I have another timer on a very short interval watching for something else to
happen. This something else is unrelated to the file system, it is updating
the status of an out of process com component.

This second timer is not firing while the long running process is taking
place, the do events is working because the status of the long running
process is updated in the status bar of the application and that works.

Is there a rule that I have missed that says only one timer event can be
running at any one time ?

Come to think of it over the years I have only ever put very short routines
in timers so have never faced such a problem.

I can think of a few ways to get around this but am wondering if you agree
with my reasoning?

All the best for the new year

Max
Jan 1 '07 #1
4 7036

"Max" <no****@spamcat chers.comwrote in message
news:45******** **************@ news.optusnet.c om.au...
This may be an elementary question but it's something I have not
encountered
in about 10 years writing code in VB 5 / 6

I have a timer that using the API checks if there has been a change to one
of several watched directories in the file system, if there has been a
change a rather long running process is started.

The long running process loops through all files comparing the last
modified
attributes on each to those in the database if there is a change the
database is updated.

Simple so far right ?

Just prior to the loop statement in that routine there is a DoEvents to
keep
everything ticking along, however something interesting happens.

I have another timer on a very short interval watching for something else
to
happen. This something else is unrelated to the file system, it is
updating
the status of an out of process com component.

This second timer is not firing while the long running process is taking
place, the do events is working because the status of the long running
process is updated in the status bar of the application and that works.

Is there a rule that I have missed that says only one timer event can be
running at any one time ?

Come to think of it over the years I have only ever put very short
routines
in timers so have never faced such a problem.

I can think of a few ways to get around this but am wondering if you agree
with my reasoning?

All the best for the new year

Max
The short answer is no - there is no 'rule' that says you can't have more
than one timer running at a time. However, you can occasionally arrange
things such that you can experience 'unexpected' behavior. <g>

As Timers are not hard interupts and a Timer event has to wait for its turn
to run, just like any other event, a long running process in one timer can
definitely effect results. The usual fix is to install judicious DoEvents in
a long running process - it sounds like you have tried that. You may just
need to do some re-arranging.

Without knowing more about your particular situation I wouldn't venture a
specific solution. But you can take heart that one is likely possible.

As a sidenote: Just in case, be aware that timers act differently when run
in debug mode (in an IDE) than when released. They also can react strangely
with MsgBoxes/Modal dialogs. So do your testing with release versions and
monitor the behavior with logs or DebugOutputStri ng and DebugViewers.

Placing Timers in a Control Array and thus having only one event (point of
entry)can often simplify the coding and make it easier to monitor the
behavior.

At the other end of the spectrum you might consider reworking your
application to using FindFirstChange Notification/FindNextChangeN otification
functions with the WaitForMultiple Objects function, and eliminate one of the
timers entirely.

hth
-ralph



Jan 1 '07 #2

"Max" <no****@spamcat chers.comwrote in message
news:45******** **************@ news.optusnet.c om.au...
>
This second timer is not firing while the long running process is taking
place, the do events is working because the status of the long running process
is updated in the status bar of the application and that works.
I would bet that the second timer is firing with each DoEvents (unless you just
have the code mangled up).

It is more likely that it is is firing, but you are not seeing the out of
process component updated as you expect.

It should be easy to put in a visual queue that the second short timer is indeed
firing during the long loop - a debug statement, a character added to a text box
on a form, whatever works.

You might well find that the issue is more to do with the out of process
component not getting any processing time to update itself, since your app is so
busy when it is in the long loop.
Jan 1 '07 #3
Max
Thanks Ralph

I will look at the re working of the code you have given me some good ideas
there and thanks for the tip on the different behaviour when running in the
IDE.

The app is one that has grown over the past 6 years and could do with a good
rethink.
Max

"Ralph" <nt************ *@yahoo.comwrot e in message
news:Gd******** *************** *******@arkansa s.net...
>
"Max" <no****@spamcat chers.comwrote in message
news:45******** **************@ news.optusnet.c om.au...
>This may be an elementary question but it's something I have not
encountered
>in about 10 years writing code in VB 5 / 6

I have a timer that using the API checks if there has been a change to
one
of several watched directories in the file system, if there has been a
change a rather long running process is started.

The long running process loops through all files comparing the last
modified
>attributes on each to those in the database if there is a change the
database is updated.

Simple so far right ?

Just prior to the loop statement in that routine there is a DoEvents to
keep
>everything ticking along, however something interesting happens.

I have another timer on a very short interval watching for something else
to
>happen. This something else is unrelated to the file system, it is
updating
>the status of an out of process com component.

This second timer is not firing while the long running process is taking
place, the do events is working because the status of the long running
process is updated in the status bar of the application and that works.

Is there a rule that I have missed that says only one timer event can be
running at any one time ?

Come to think of it over the years I have only ever put very short
routines
>in timers so have never faced such a problem.

I can think of a few ways to get around this but am wondering if you
agree
with my reasoning?

All the best for the new year

Max

The short answer is no - there is no 'rule' that says you can't have more
than one timer running at a time. However, you can occasionally arrange
things such that you can experience 'unexpected' behavior. <g>

As Timers are not hard interupts and a Timer event has to wait for its
turn
to run, just like any other event, a long running process in one timer can
definitely effect results. The usual fix is to install judicious DoEvents
in
a long running process - it sounds like you have tried that. You may just
need to do some re-arranging.

Without knowing more about your particular situation I wouldn't venture a
specific solution. But you can take heart that one is likely possible.

As a sidenote: Just in case, be aware that timers act differently when run
in debug mode (in an IDE) than when released. They also can react
strangely
with MsgBoxes/Modal dialogs. So do your testing with release versions and
monitor the behavior with logs or DebugOutputStri ng and DebugViewers.

Placing Timers in a Control Array and thus having only one event (point of
entry)can often simplify the coding and make it easier to monitor the
behavior.

At the other end of the spectrum you might consider reworking your
application to using
FindFirstChange Notification/FindNextChangeN otification
functions with the WaitForMultiple Objects function, and eliminate one of
the
timers entirely.

hth
-ralph



Jan 1 '07 #4
Max
Thanks Steve,

I had a break in the 2nd timer event that was not being hit but I will do
the visual test. and run it as an EXE

The out of process component is media player and the audio is playing
without a hiccup however your suggestion my be correct it that its not
returning it's position because there is no processor time.

All the best
Max

"Steve Gerrard" <my********@com cast.netwrote in message
news:0O******** *************** *******@comcast .com...
>
"Max" <no****@spamcat chers.comwrote in message
news:45******** **************@ news.optusnet.c om.au...
>>
This second timer is not firing while the long running process is taking
place, the do events is working because the status of the long running
process is updated in the status bar of the application and that works.

I would bet that the second timer is firing with each DoEvents (unless you
just have the code mangled up).

It is more likely that it is is firing, but you are not seeing the out of
process component updated as you expect.

It should be easy to put in a visual queue that the second short timer is
indeed firing during the long loop - a debug statement, a character added
to a text box on a form, whatever works.

You might well find that the issue is more to do with the out of process
component not getting any processing time to update itself, since your app
is so busy when it is in the long loop.


Jan 1 '07 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
31216
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 http://searchvb.techtarget.com/tip/1,289483,sid8_gci535495,00.html which has the following: > Want to really get down to instants? This tip from reader Phil Lenoir tells you how. >...
13
7500
by: Manuel Lopez | last post by:
I have a puzzling form timer problem that I didn't experience prior to Access 2003 (though I'm not sure access 2003 is to blame). Here's the situation: a computer has two access 2003 databases on it, a frontend and a backend. Case 1: If vba code on the frontend updates many rows (360,000) on the backend, a form's timer event (from the frontend) will stop firing until the user gives the form focus. (Note that the update itself always...
11
2569
by: Steve Jorgensen | last post by:
I've recently been playing with some UI ideas that require the user of a timer to drive animation. The problem I'm having is that Access routinely stops firing timer events for long periods of time. For example, the user types a character in another window, and the timer stops. The user types another key, and the timer starts again, runs for a few seconds, then stops again. Now, the code I'm writing would easily tolerate a few...
6
2885
by: Dan | last post by:
I've created a pocketpc app which has a startup form containing a listview. The form creates an object which in turn creates a System.Threading.Timer. It keeps track of the Timer state using a TimerState object similar to the example in the System.Threading.Timer documentation. The method which handles the timer events, among other things, periodically calls a method in this TimerState object which raises an event to the startup form,...
3
2339
by: Kenny | last post by:
I am running a windows service that takes actions based on a couple System.Threading.Timers. The intervals are usually short... based on the time of day, anywhere between 1 and 5 minutes. Recently however, the event that was firing based on the timer started firing rapidly; it fired about 9000 times in a minute and a half. After the minute and a half was up, it returned to normal behavior! .... just wondering if anyone has experienced...
4
3342
by: Dan | last post by:
Hi, I have a timer on a form (System.Windows.Forms.Timer - Framework 1.1) that is set to 60 seconds as sort an of inactivity monitor. If 60 seconds have elapsed without any user activity I want the form to close. I stop/start the timer at button clicks and keydown events etc of the various controls on the form. Users have reported the form closing in the middle of them typing or immediately after opening the form (but only rarely)....
2
2483
by: r norman | last post by:
Please excuse the cross-posting. This question was raised in microsoft.public.dotnet.general but hasn't been answered so I am trying where I can. There are two of us who have the same problem in a service: the Timer::Tick event processor never gets called. We have set the timer interval, enabled it, and started it, but still nothing. In my case, I also have enabled an event handler to detect SessionSwitch, but that never gets...
4
5376
by: Ben | last post by:
Hello everybody I got confused by this problem for which I don't have a logical explanation. There is a Thread (ThreadA) which receives Events from another system thread (ThreadS). ThreadA then adds a time stamp to the received event and adds it to a event queue. This works well (therfore not shown here). The queue fills up. Then I used a timer to check every millisecond for new events in the queue and send it to another thread...
5
12249
by: Tony Gravagno | last post by:
I have a class that instantiates two Timer objects that fire at different intervals. My class can be instantiated within a Windows Form or from a Windows Service. Actions performed by one of the event handlers may take longer than the interval for either of the timers, so it's possible for multiple events to fire "simultaneously" and for events to queue up. I'm attempting to get the timers to sync on some reference type object, or use...
4
4639
by: grayaii | last post by:
Hi, I have a simple form that handles all its paint functionality like so: this.SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.Opaque, true); And the entry point to this program is like so: static void Main() {
0
10217
jinu1996
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10168
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10003
tracyyun
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9047
agi2029
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7546
isladogs
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6785
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5440
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4114
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3730
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.