Home All Groups Group Topic Archive Search About
Author
4 Feb 2006 4:24 AM
Jack
Hello,
1.
Is there any 'optimal' number of timers can be used on one form?
2.
Which design will be more efficient:
A. using one timer and combine different events using If... Then
statements.
      Because each event requires different time interval change timer
intervals for each event will be included in the code
or
B.
For each event use different timer with preset time interval

Your thoughts please,
Jack

Author
4 Feb 2006 4:54 PM
Veign
What are you trying to do?

Option:
One timer with a low interval (1 second maybe) and have the timer event
check for how much time has passed and react accordingly.  Then your timer
event can trigger several events based on passed time.

Remember timer events are low priority events with the system and instead of
checking for a time being reached you should check for a time being
passed...

--
Chris Hanscom - Microsoft MVP (VB)
Veign's Resource Center
http://www.veign.com/vrc_main.asp
Veign's Blog
http://www.veign.com/blog
--


Show quoteHide quote
"Jack" <replyTo@newsgroup> wrote in message
news:OJ$FmLUKGHA.1676@TK2MSFTNGP09.phx.gbl...
> Hello,
> 1.
> Is there any 'optimal' number of timers can be used on one form?
> 2.
> Which design will be more efficient:
> A. using one timer and combine different events using If... Then
> statements.
>      Because each event requires different time interval change timer
> intervals for each event will be included in the code
> or
> B.
> For each event use different timer with preset time interval
>
> Your thoughts please,
> Jack
>
>
Are all your drivers up to date? click for free checkup

Author
4 Feb 2006 4:56 PM
Michael D. Ober
I have always run multiple timers in this situation.  Name the timers so
that the timer_Elapsed events are obvious.  This will make you code more
readable.

Mike Ober.

Show quoteHide quote
"Jack" <replyTo@newsgroup> wrote in message
news:OJ$FmLUKGHA.1676@TK2MSFTNGP09.phx.gbl...
> Hello,
> 1.
> Is there any 'optimal' number of timers can be used on one form?
> 2.
> Which design will be more efficient:
>  A. using one timer and combine different events using If... Then
> statements.
>       Because each event requires different time interval change timer
> intervals for each event will be included in the code
> or
> B.
> For each event use different timer with preset time interval
>
> Your thoughts please,
> Jack
>
>
>
Author
4 Feb 2006 9:20 PM
Jack
Thank you.
What I am worrying about is that my form has already 15 timers on it and I
am in need to add some more.
Not all the timers are active at the same time of course, but one or two.
I do not want to have big overhead, or the code became too 'heavy'.
Jack
Show quoteHide quote
"Jack" <replyTo@newsgroup> wrote in message
news:OJ$FmLUKGHA.1676@TK2MSFTNGP09.phx.gbl...
> Hello,
> 1.
> Is there any 'optimal' number of timers can be used on one form?
> 2.
> Which design will be more efficient:
> A. using one timer and combine different events using If... Then
> statements.
>      Because each event requires different time interval change timer
> intervals for each event will be included in the code
> or
> B.
> For each event use different timer with preset time interval
>
> Your thoughts please,
> Jack
>
>
Author
4 Feb 2006 9:23 PM
Veign
Again, I ask, what are you trying to do?  By explaining what you ware doing
you may get alternate methods that will work better.  When you ask a
specific question you get specific answers - as we don't how or why things
are being used...

Like, 15 timers on a form, to me, seems very excessive.  I have probably
never used more than 3.....

--
Chris Hanscom - Microsoft MVP (VB)
Veign's Resource Center
http://www.veign.com/vrc_main.asp
Veign's Blog
http://www.veign.com/blog
--


Show quoteHide quote
"Jack" <replyTo@newsgroup> wrote in message
news:u1zCgDdKGHA.2300@TK2MSFTNGP15.phx.gbl...
> Thank you.
> What I am worrying about is that my form has already 15 timers on it and I
> am in need to add some more.
> Not all the timers are active at the same time of course, but one or two.
> I do not want to have big overhead, or the code became too 'heavy'.
> Jack
> "Jack" <replyTo@newsgroup> wrote in message
> news:OJ$FmLUKGHA.1676@TK2MSFTNGP09.phx.gbl...
>> Hello,
>> 1.
>> Is there any 'optimal' number of timers can be used on one form?
>> 2.
>> Which design will be more efficient:
>> A. using one timer and combine different events using If... Then
>> statements.
>>      Because each event requires different time interval change timer
>> intervals for each event will be included in the code
>> or
>> B.
>> For each event use different timer with preset time interval
>>
>> Your thoughts please,
>> Jack
>>
>>
>
>
Author
4 Feb 2006 10:01 PM
Jack
It is a communication program.
timers are used for:
-main timer --> heart of the system
-retrieving TAPI callbacks
-detecting busy line
-scheduler
-recording
-playing
-running script
-finding specified window (FindWindow() )
-redirecting voice
-buffering
-monitoring

should I go on?
Jack


Show quoteHide quote
"Veign" <NOSPAMinveign@veign.com> wrote in message
news:OLwhKHdKGHA.2828@TK2MSFTNGP12.phx.gbl...
> Again, I ask, what are you trying to do?  By explaining what you ware
> doing you may get alternate methods that will work better.  When you ask a
> specific question you get specific answers - as we don't how or why things
> are being used...
>
> Like, 15 timers on a form, to me, seems very excessive.  I have probably
> never used more than 3.....
>
> --
> Chris Hanscom - Microsoft MVP (VB)
> Veign's Resource Center
> http://www.veign.com/vrc_main.asp
> Veign's Blog
> http://www.veign.com/blog
> --
>
>
> "Jack" <replyTo@newsgroup> wrote in message
> news:u1zCgDdKGHA.2300@TK2MSFTNGP15.phx.gbl...
>> Thank you.
>> What I am worrying about is that my form has already 15 timers on it and
>> I am in need to add some more.
>> Not all the timers are active at the same time of course, but one or two.
>> I do not want to have big overhead, or the code became too 'heavy'.
>> Jack
>> "Jack" <replyTo@newsgroup> wrote in message
>> news:OJ$FmLUKGHA.1676@TK2MSFTNGP09.phx.gbl...
>>> Hello,
>>> 1.
>>> Is there any 'optimal' number of timers can be used on one form?
>>> 2.
>>> Which design will be more efficient:
>>> A. using one timer and combine different events using If... Then
>>> statements.
>>>      Because each event requires different time interval change timer
>>> intervals for each event will be included in the code
>>> or
>>> B.
>>> For each event use different timer with preset time interval
>>>
>>> Your thoughts please,
>>> Jack
>>>
>>>
>>
>>
>
>
Author
4 Feb 2006 10:03 PM
Veign
Good luck.  You seem very hesistant to give information and when you do you
come across with an attitude.  I was trying to help.

To answer your question - No, you don't need to go on....

--
Chris Hanscom - Microsoft MVP (VB)
Veign's Resource Center
http://www.veign.com/vrc_main.asp
Veign's Blog
http://www.veign.com/blog
--


Show quoteHide quote
"Jack" <replyTo@newsgroup> wrote in message
news:%23AynTadKGHA.3896@TK2MSFTNGP15.phx.gbl...
> It is a communication program.
> timers are used for:
> -main timer --> heart of the system
> -retrieving TAPI callbacks
> -detecting busy line
> -scheduler
> -recording
> -playing
> -running script
> -finding specified window (FindWindow() )
> -redirecting voice
> -buffering
> -monitoring
>
> should I go on?
> Jack
>
>
> "Veign" <NOSPAMinveign@veign.com> wrote in message
> news:OLwhKHdKGHA.2828@TK2MSFTNGP12.phx.gbl...
>> Again, I ask, what are you trying to do?  By explaining what you ware
>> doing you may get alternate methods that will work better.  When you ask
>> a specific question you get specific answers - as we don't how or why
>> things are being used...
>>
>> Like, 15 timers on a form, to me, seems very excessive.  I have probably
>> never used more than 3.....
>>
>> --
>> Chris Hanscom - Microsoft MVP (VB)
>> Veign's Resource Center
>> http://www.veign.com/vrc_main.asp
>> Veign's Blog
>> http://www.veign.com/blog
>> --
>>
>>
>> "Jack" <replyTo@newsgroup> wrote in message
>> news:u1zCgDdKGHA.2300@TK2MSFTNGP15.phx.gbl...
>>> Thank you.
>>> What I am worrying about is that my form has already 15 timers on it and
>>> I am in need to add some more.
>>> Not all the timers are active at the same time of course, but one or
>>> two.
>>> I do not want to have big overhead, or the code became too 'heavy'.
>>> Jack
>>> "Jack" <replyTo@newsgroup> wrote in message
>>> news:OJ$FmLUKGHA.1676@TK2MSFTNGP09.phx.gbl...
>>>> Hello,
>>>> 1.
>>>> Is there any 'optimal' number of timers can be used on one form?
>>>> 2.
>>>> Which design will be more efficient:
>>>> A. using one timer and combine different events using If... Then
>>>> statements.
>>>>      Because each event requires different time interval change timer
>>>> intervals for each event will be included in the code
>>>> or
>>>> B.
>>>> For each event use different timer with preset time interval
>>>>
>>>> Your thoughts please,
>>>> Jack
>>>>
>>>>
>>>
>>>
>>
>>
>
>
Author
4 Feb 2006 10:19 PM
Jack
No need to get offended. If you are,  I apologize.
I have just tried to answer your question.
You asked me what I am trying to do and I explained.
Each timer has specific task as shown. At most only one or two timers are
active at the same time.
What  I am trying to find is how that timers are weighting on my code?
Is there a better approach to reduce number of timers and cumulate more code
inside them?
It was my original question, btw,
Jack

Show quoteHide quote
"Veign" <NOSPAMinveign@veign.com> wrote in message
news:enwL%23ddKGHA.524@TK2MSFTNGP09.phx.gbl...
> Good luck.  You seem very hesistant to give information and when you do
> you come across with an attitude.  I was trying to help.
>
> To answer your question - No, you don't need to go on....
>
> --
> Chris Hanscom - Microsoft MVP (VB)
> Veign's Resource Center
> http://www.veign.com/vrc_main.asp
> Veign's Blog
> http://www.veign.com/blog
> --
>
>
> "Jack" <replyTo@newsgroup> wrote in message
> news:%23AynTadKGHA.3896@TK2MSFTNGP15.phx.gbl...
>> It is a communication program.
>> timers are used for:
>> -main timer --> heart of the system
>> -retrieving TAPI callbacks
>> -detecting busy line
>> -scheduler
>> -recording
>> -playing
>> -running script
>> -finding specified window (FindWindow() )
>> -redirecting voice
>> -buffering
>> -monitoring
>>
>> should I go on?
>> Jack
>>
>>
>> "Veign" <NOSPAMinveign@veign.com> wrote in message
>> news:OLwhKHdKGHA.2828@TK2MSFTNGP12.phx.gbl...
>>> Again, I ask, what are you trying to do?  By explaining what you ware
>>> doing you may get alternate methods that will work better.  When you ask
>>> a specific question you get specific answers - as we don't how or why
>>> things are being used...
>>>
>>> Like, 15 timers on a form, to me, seems very excessive.  I have probably
>>> never used more than 3.....
>>>
>>> --
>>> Chris Hanscom - Microsoft MVP (VB)
>>> Veign's Resource Center
>>> http://www.veign.com/vrc_main.asp
>>> Veign's Blog
>>> http://www.veign.com/blog
>>> --
>>>
>>>
>>> "Jack" <replyTo@newsgroup> wrote in message
>>> news:u1zCgDdKGHA.2300@TK2MSFTNGP15.phx.gbl...
>>>> Thank you.
>>>> What I am worrying about is that my form has already 15 timers on it
>>>> and I am in need to add some more.
>>>> Not all the timers are active at the same time of course, but one or
>>>> two.
>>>> I do not want to have big overhead, or the code became too 'heavy'.
>>>> Jack
>>>> "Jack" <replyTo@newsgroup> wrote in message
>>>> news:OJ$FmLUKGHA.1676@TK2MSFTNGP09.phx.gbl...
>>>>> Hello,
>>>>> 1.
>>>>> Is there any 'optimal' number of timers can be used on one form?
>>>>> 2.
>>>>> Which design will be more efficient:
>>>>> A. using one timer and combine different events using If... Then
>>>>> statements.
>>>>>      Because each event requires different time interval change timer
>>>>> intervals for each event will be included in the code
>>>>> or
>>>>> B.
>>>>> For each event use different timer with preset time interval
>>>>>
>>>>> Your thoughts please,
>>>>> Jack
>>>>>
>>>>>
>>>>
>>>>
>>>
>>>
>>
>>
>
>
Author
5 Feb 2006 4:12 AM
Veign
OK..

You really haven't provided enough information on coming up with an
alternate solution.  By the sound of the complexity of your application I'm
not sure you could.  What's hard to tell is the why.  Like why does running
a script require a timer or why does finding a window need a timer.

I guess I stand by my original statement that a single timer that monitors
all the events is the way to go.  Also, its hard to tell if you even need
everything on timers.

Maybe what you could do is start consolidating timers that perform a common
function like; Recording, playback, redirect.  See how this works for you
and keep moving in the direction of removing timers and not adding new
ones...

Also, I guess it would be nice to try and understand 'why so many things
need times'

--
Chris Hanscom - Microsoft MVP (VB)
Veign's Resource Center
http://www.veign.com/vrc_main.asp
Veign's Blog
http://www.veign.com/blog
--


Show quoteHide quote
"Jack" <replyTo@newsgroup> wrote in message
news:eDwAHkdKGHA.3144@TK2MSFTNGP11.phx.gbl...
> No need to get offended. If you are,  I apologize.
> I have just tried to answer your question.
> You asked me what I am trying to do and I explained.
> Each timer has specific task as shown. At most only one or two timers are
> active at the same time.
> What  I am trying to find is how that timers are weighting on my code?
> Is there a better approach to reduce number of timers and cumulate more
> code inside them?
> It was my original question, btw,
> Jack
>
> "Veign" <NOSPAMinveign@veign.com> wrote in message
> news:enwL%23ddKGHA.524@TK2MSFTNGP09.phx.gbl...
>> Good luck.  You seem very hesistant to give information and when you do
>> you come across with an attitude.  I was trying to help.
>>
>> To answer your question - No, you don't need to go on....
>>
>> --
>> Chris Hanscom - Microsoft MVP (VB)
>> Veign's Resource Center
>> http://www.veign.com/vrc_main.asp
>> Veign's Blog
>> http://www.veign.com/blog
>> --
>>
>>
>> "Jack" <replyTo@newsgroup> wrote in message
>> news:%23AynTadKGHA.3896@TK2MSFTNGP15.phx.gbl...
>>> It is a communication program.
>>> timers are used for:
>>> -main timer --> heart of the system
>>> -retrieving TAPI callbacks
>>> -detecting busy line
>>> -scheduler
>>> -recording
>>> -playing
>>> -running script
>>> -finding specified window (FindWindow() )
>>> -redirecting voice
>>> -buffering
>>> -monitoring
>>>
>>> should I go on?
>>> Jack
>>>
>>>
>>> "Veign" <NOSPAMinveign@veign.com> wrote in message
>>> news:OLwhKHdKGHA.2828@TK2MSFTNGP12.phx.gbl...
>>>> Again, I ask, what are you trying to do?  By explaining what you ware
>>>> doing you may get alternate methods that will work better.  When you
>>>> ask a specific question you get specific answers - as we don't how or
>>>> why things are being used...
>>>>
>>>> Like, 15 timers on a form, to me, seems very excessive.  I have
>>>> probably never used more than 3.....
>>>>
>>>> --
>>>> Chris Hanscom - Microsoft MVP (VB)
>>>> Veign's Resource Center
>>>> http://www.veign.com/vrc_main.asp
>>>> Veign's Blog
>>>> http://www.veign.com/blog
>>>> --
>>>>
>>>>
>>>> "Jack" <replyTo@newsgroup> wrote in message
>>>> news:u1zCgDdKGHA.2300@TK2MSFTNGP15.phx.gbl...
>>>>> Thank you.
>>>>> What I am worrying about is that my form has already 15 timers on it
>>>>> and I am in need to add some more.
>>>>> Not all the timers are active at the same time of course, but one or
>>>>> two.
>>>>> I do not want to have big overhead, or the code became too 'heavy'.
>>>>> Jack
>>>>> "Jack" <replyTo@newsgroup> wrote in message
>>>>> news:OJ$FmLUKGHA.1676@TK2MSFTNGP09.phx.gbl...
>>>>>> Hello,
>>>>>> 1.
>>>>>> Is there any 'optimal' number of timers can be used on one form?
>>>>>> 2.
>>>>>> Which design will be more efficient:
>>>>>> A. using one timer and combine different events using If... Then
>>>>>> statements.
>>>>>>      Because each event requires different time interval change timer
>>>>>> intervals for each event will be included in the code
>>>>>> or
>>>>>> B.
>>>>>> For each event use different timer with preset time interval
>>>>>>
>>>>>> Your thoughts please,
>>>>>> Jack
>>>>>>
>>>>>>
>>>>>
>>>>>
>>>>
>>>>
>>>
>>>
>>
>>
>
>
Author
5 Feb 2006 5:23 AM
TedF
Even though with one timer, still none will work
with the intervals you expect.  Because VB can do one thing
at a time, and by the time you expect it to run your function
at the interval you set, it will be busy doing the first function.

You have to run things in sequence rather than by timer intervals.
And don't expect it to run things for you in intervals of 250 or 500,
because it would take that long to run your first function.

Yes timers do run in the background, but will not function
if you have it busy doing something else.

Use one timer.
Set a long variable to count time, then call functions
when the variable reaches time desired.


'Example:
Dim T500 As Long, T750 As Long, T1000 As Long, T1250 As Long
Private Sub Form_Load()
Timer1.Interval = 250
End Sub

Private Sub Timer1_Timer()
T500 = T500 + 1
If T500 = 2 Then
T500 = 0
Call theFunction500
End If

T750 = T750 + 1
If T750 = 3 Then
T750 = 0
Call theFunction750
End If

T1000 = T1000 + 1
If T1000 = 4 Then
T1000 = 0
Call theFunction1000
End If
End Sub
Public Sub theFunction500()
MsgBox "500"
End Sub
Public Sub theFunction750()
MsgBox "750"
End Sub
Public Sub theFunction1000()
MsgBox "1000"
End Sub



Show quoteHide quote
"Jack" <replyTo@newsgroup> wrote in message
news:eDwAHkdKGHA.3144@TK2MSFTNGP11.phx.gbl...
> No need to get offended. If you are,  I apologize.
> I have just tried to answer your question.
> You asked me what I am trying to do and I explained.
> Each timer has specific task as shown. At most only one or two timers are
> active at the same time.
> What  I am trying to find is how that timers are weighting on my code?
> Is there a better approach to reduce number of timers and cumulate more
> code inside them?
> It was my original question, btw,
> Jack
>
> "Veign" <NOSPAMinveign@veign.com> wrote in message
> news:enwL%23ddKGHA.524@TK2MSFTNGP09.phx.gbl...
>> Good luck.  You seem very hesistant to give information and when you do
>> you come across with an attitude.  I was trying to help.
>>
>> To answer your question - No, you don't need to go on....
>>
>> --
>> Chris Hanscom - Microsoft MVP (VB)
>> Veign's Resource Center
>> http://www.veign.com/vrc_main.asp
>> Veign's Blog
>> http://www.veign.com/blog
>> --
>>
>>
>> "Jack" <replyTo@newsgroup> wrote in message
>> news:%23AynTadKGHA.3896@TK2MSFTNGP15.phx.gbl...
>>> It is a communication program.
>>> timers are used for:
>>> -main timer --> heart of the system
>>> -retrieving TAPI callbacks
>>> -detecting busy line
>>> -scheduler
>>> -recording
>>> -playing
>>> -running script
>>> -finding specified window (FindWindow() )
>>> -redirecting voice
>>> -buffering
>>> -monitoring
>>>
>>> should I go on?
>>> Jack
>>>
>>>
>>> "Veign" <NOSPAMinveign@veign.com> wrote in message
>>> news:OLwhKHdKGHA.2828@TK2MSFTNGP12.phx.gbl...
>>>> Again, I ask, what are you trying to do?  By explaining what you ware
>>>> doing you may get alternate methods that will work better.  When you
>>>> ask a specific question you get specific answers - as we don't how or
>>>> why things are being used...
>>>>
>>>> Like, 15 timers on a form, to me, seems very excessive.  I have
>>>> probably never used more than 3.....
>>>>
>>>> --
>>>> Chris Hanscom - Microsoft MVP (VB)
>>>> Veign's Resource Center
>>>> http://www.veign.com/vrc_main.asp
>>>> Veign's Blog
>>>> http://www.veign.com/blog
>>>> --
>>>>
>>>>
>>>> "Jack" <replyTo@newsgroup> wrote in message
>>>> news:u1zCgDdKGHA.2300@TK2MSFTNGP15.phx.gbl...
>>>>> Thank you.
>>>>> What I am worrying about is that my form has already 15 timers on it
>>>>> and I am in need to add some more.
>>>>> Not all the timers are active at the same time of course, but one or
>>>>> two.
>>>>> I do not want to have big overhead, or the code became too 'heavy'.
>>>>> Jack
>>>>> "Jack" <replyTo@newsgroup> wrote in message
>>>>> news:OJ$FmLUKGHA.1676@TK2MSFTNGP09.phx.gbl...
>>>>>> Hello,
>>>>>> 1.
>>>>>> Is there any 'optimal' number of timers can be used on one form?
>>>>>> 2.
>>>>>> Which design will be more efficient:
>>>>>> A. using one timer and combine different events using If... Then
>>>>>> statements.
>>>>>>      Because each event requires different time interval change timer
>>>>>> intervals for each event will be included in the code
>>>>>> or
>>>>>> B.
>>>>>> For each event use different timer with preset time interval
>>>>>>
>>>>>> Your thoughts please,
>>>>>> Jack
>>>>>>
>>>>>>
>>>>>
>>>>>
>>>>
>>>>
>>>
>>>
>>
>>
>
>
Author
5 Feb 2006 1:29 AM
Larry Serflaten
"Jack" <replyTo@newsgroup> wrote
> Hello,
> 1.
> Is there any 'optimal' number of timers can be used on one form?

Yes, the optimal number might be just one.

> 2.
> Which design will be more efficient:
>  A. using one timer and combine different events using If... Then
> statements.

Using less timers would be better.  No matter how many timers you
use, you can only execute in one routine at a time anyway....

LFS

Bookmark and Share