473,396 Members | 1,693 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Question regarding timer.

Hi all,

I am using timer to do some functionality on user specified time.

I am using system.timers.timer class and its timer to do this
functionality. What i am doing is i set autoreset to false as i want to
start processing only on user specified time.

I am setting interval as difference between user sepcified time and
current time. And when that elapsed event occured i am again setting
interval to new value with autoreset to false as i want to fire event
only once.

Means everytime i am reinitializing timer.

There is another solution and that is set autoreset to true and set
interval to say 1 min and in every min check current time with user
specified time. But this will cause timer to get fire every time.

so which one is better solution?

Can someone help me in deciding which i need to implement,

Any help will be truely appreciated.

Thanks in advance.

Jun 26 '06 #1
5 1783
archana wrote:
I am using system.timers.timer class and its timer to do this
functionality. What i am doing is i set autoreset to false as i want to
start processing only on user specified time.

I am setting interval as difference between user sepcified time and
current time. And when that elapsed event occured i am again setting
interval to new value with autoreset to false as i want to fire event
only once.

Means everytime i am reinitializing timer.
That doesn't sound especially hard or messy - so no problem with this approach.
The advantage is that the timer only fires when you have something to do.
There is another solution and that is set autoreset to true and set
interval to say 1 min and in every min check current time with user
specified time. But this will cause timer to get fire every time.
If one-minute granularity is good enough for your application then there is no
real problem with this approach either. The additional processing overhead is
insignificant. It may be slightly simpler to implement.
so which one is better solution?
Can someone help me in deciding which i need to implement,


Either one is fine - quit agonizing, just pick one and get on with it. I would
do it the first way, but only for esthetic (old fart) reasons.

HTH,
-rick-
Jun 26 '06 #2
Hi, Rick

Thanks for your reply.
I was slight confuse regarding overheads in both approach.

But u cleared my confusion.

thanks a lot.

Rick Lones wrote:
archana wrote:
I am using system.timers.timer class and its timer to do this
functionality. What i am doing is i set autoreset to false as i want to
start processing only on user specified time.

I am setting interval as difference between user sepcified time and
current time. And when that elapsed event occured i am again setting
interval to new value with autoreset to false as i want to fire event
only once.

Means everytime i am reinitializing timer.


That doesn't sound especially hard or messy - so no problem with this approach.
The advantage is that the timer only fires when you have something to do.
There is another solution and that is set autoreset to true and set
interval to say 1 min and in every min check current time with user
specified time. But this will cause timer to get fire every time.


If one-minute granularity is good enough for your application then there is no
real problem with this approach either. The additional processing overhead is
insignificant. It may be slightly simpler to implement.
so which one is better solution?
Can someone help me in deciding which i need to implement,


Either one is fine - quit agonizing, just pick one and get on with it. I would
do it the first way, but only for esthetic (old fart) reasons.

HTH,
-rick-


Jun 26 '06 #3
Hi,

I have one more question regarding timer.

When timer's elapsed event is fire at that time in debug window i am
getting following msg
'The thread '<No Name>' (0x494) has exited with code 0 (0x0).'

can u tell me why this mesage is coming. This is not coming every time.

Thanks in advance.

archana wrote:
Hi, Rick

Thanks for your reply.
I was slight confuse regarding overheads in both approach.

But u cleared my confusion.

thanks a lot.

Rick Lones wrote:
archana wrote:
I am using system.timers.timer class and its timer to do this
functionality. What i am doing is i set autoreset to false as i want to
start processing only on user specified time.

I am setting interval as difference between user sepcified time and
current time. And when that elapsed event occured i am again setting
interval to new value with autoreset to false as i want to fire event
only once.

Means everytime i am reinitializing timer.


That doesn't sound especially hard or messy - so no problem with this approach.
The advantage is that the timer only fires when you have something to do.
There is another solution and that is set autoreset to true and set
interval to say 1 min and in every min check current time with user
specified time. But this will cause timer to get fire every time.


If one-minute granularity is good enough for your application then there is no
real problem with this approach either. The additional processing overhead is
insignificant. It may be slightly simpler to implement.
so which one is better solution?
Can someone help me in deciding which i need to implement,


Either one is fine - quit agonizing, just pick one and get on with it. I would
do it the first way, but only for esthetic (old fart) reasons.

HTH,
-rick-


Jun 27 '06 #4
The message means that nothing bad happened when the thread exited. A return
value of 0 from a thread is an exception-less return.

--
HTH,

Kevin Spencer
Microsoft MVP
Professional Chicken Salad Alchemist

Big thicks are made up of lots of little thins.
"archana" <tr**************@yahoo.com> wrote in message
news:11**********************@u72g2000cwu.googlegr oups.com...
Hi,

I have one more question regarding timer.

When timer's elapsed event is fire at that time in debug window i am
getting following msg
'The thread '<No Name>' (0x494) has exited with code 0 (0x0).'

can u tell me why this mesage is coming. This is not coming every time.

Thanks in advance.

archana wrote:
Hi, Rick

Thanks for your reply.
I was slight confuse regarding overheads in both approach.

But u cleared my confusion.

thanks a lot.

Rick Lones wrote:
> archana wrote:
> > I am using system.timers.timer class and its timer to do this
> > functionality. What i am doing is i set autoreset to false as i want
> > to
> > start processing only on user specified time.
> >
> > I am setting interval as difference between user sepcified time and
> > current time. And when that elapsed event occured i am again setting
> > interval to new value with autoreset to false as i want to fire event
> > only once.
> >
> > Means everytime i am reinitializing timer.
>
> That doesn't sound especially hard or messy - so no problem with this
> approach.
> The advantage is that the timer only fires when you have something to
> do.
>
> > There is another solution and that is set autoreset to true and set
> > interval to say 1 min and in every min check current time with user
> > specified time. But this will cause timer to get fire every time.
>
> If one-minute granularity is good enough for your application then
> there is no
> real problem with this approach either. The additional processing
> overhead is
> insignificant. It may be slightly simpler to implement.
>
> > so which one is better solution?
> > Can someone help me in deciding which i need to implement,
>
> Either one is fine - quit agonizing, just pick one and get on with it.
> I would
> do it the first way, but only for esthetic (old fart) reasons.
>
> HTH,
> -rick-

Jun 27 '06 #5
I agree. I like the idea of manually controlling the set of the next event
incase I need to cancel or something. I makes me uneasy to have those
events going off every minute out-side my control. Method 1 also lets you
adjust for any minor drift, etc.

--
William Stacey [MVP]

"Rick Lones" <Wr******@YcharterZ.net> wrote in message
news:rY***************@fe06.lga...
| archana wrote:
| > I am using system.timers.timer class and its timer to do this
| > functionality. What i am doing is i set autoreset to false as i want to
| > start processing only on user specified time.
| >
| > I am setting interval as difference between user sepcified time and
| > current time. And when that elapsed event occured i am again setting
| > interval to new value with autoreset to false as i want to fire event
| > only once.
| >
| > Means everytime i am reinitializing timer.
|
| That doesn't sound especially hard or messy - so no problem with this
approach.
| The advantage is that the timer only fires when you have something to do.
|
| > There is another solution and that is set autoreset to true and set
| > interval to say 1 min and in every min check current time with user
| > specified time. But this will cause timer to get fire every time.
|
| If one-minute granularity is good enough for your application then there
is no
| real problem with this approach either. The additional processing
overhead is
| insignificant. It may be slightly simpler to implement.
|
| > so which one is better solution?
| > Can someone help me in deciding which i need to implement,
|
| Either one is fine - quit agonizing, just pick one and get on with it. I
would
| do it the first way, but only for esthetic (old fart) reasons.
|
| HTH,
| -rick-
Jun 28 '06 #6

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

Similar topics

2
by: krael | last post by:
Hello people. Right now im sitting at work trying to figure out how to work with time in php. My problem is, Im working with a test which some of our foreign costumers have to try to test...
5
by: Richard P | last post by:
I need some help on timers. My app is asp.net 1.1 website running in a shared hosting environment with a third-party service provider. I currently request and cache 20 - 40 remote RSS feeds. When a...
1
by: rahul8143 | last post by:
hello, In kernel source code there is ip_fragment.c file my question is regarding pointer function and casting for that look at required snippet from that file There is structure defined for...
1
by: Mvk | last post by:
Hi; I have a little "timer"-application. The timer starts running when I press the "CTRL + Space" buttons. The timer ends when I click again on "CTRL + Space". Resetting the timer: "CTRL +...
1
by: Paul Tomlinson | last post by:
Question about a System.Threading.Timer object and the "state" object you pass to it... Timer stateTimer = new Timer( = new TimerCallback( OnTimer ), o, 1000, 1000); I have an array of timer...
9
by: Zach | last post by:
I would like to express the time with the time continually changing. I can get it to show once, but then it stays that way, using a loop jams. Is there a way to do this?
10
by: Vincent | last post by:
Hi, I was trying to do something in a Thread that starts by a timer. I turn off the timer at the begining of the thread incase it fires again when the thread is still running. Then turn on the...
5
by: Tom | last post by:
Using multiple System.Timers.Timer objects in a Windows Service for performing multi-thread activities in a periodic fashion. Timers are AutoReset=false, to only have a single timer execution...
3
by: archana | last post by:
Hi all, I have one confusion regarding threading in windows service which is developed in c#. What i am doing is on 'onstart' event i am starting one thread. In thread procedure i am...
0
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...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
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...
0
marktang
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,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
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...
0
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,...

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.