471,350 Members | 1,852 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

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

issue in server based timer/

Hi all
I am having application which is using server based timer that is timer
from namespace system.timer.

I am having windows service which i want to run everyday at some fix
time.
In service.cs class i am creating one worker thread and in thread
procedure i am enabling one timer after thread procedure is completed
and in timer's elapsed event i am recalling my function of actual
processing.

But even if i set interval as 24 hours my code is sometime running
continuously.

Can some one tell me why thisis happening. Or can't i start timer in
thread procedure at the end of thread procedure.

Please help me.

thanks in advance,

Feb 20 '06 #1
3 1319
paste some code.
Feb 20 '06 #2
Hi,

Here i am pasting my code
Code in my thread procedure is :-

public void StartProcess()
{
success = StartSearch

if (success)
{
mTimer.Elapsed += new ElapsedEventHandler(OnTimedEvent);
mTimer.Interval = 60000 * 1440; // means 24 hours
mTimer.Enabled = true;
}
}
private void OnTimedEvent(object source, ElapsedEventArgs e)
{
StartSearch();
}
Here i am expecting that ontimedevent shoudl raised only after 24 hours
which is not happening always.

And that to at randome considtion ontimedevent is getting called before
next 24 hours.

If u know answer please let me know.

Thanks in advance.

Feb 20 '06 #3
Archana,
Having a windows serice taking up resources with a timer and running 24
hours a day just to execute a process once in 24 hours is not an efficient
way to get the job done. I believe you would be better served by compiling
this into a Console Exe app, get rid of the now unnecessary timer, and have
it run as a Scheduled Task at the appropriate time.
Peter

--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com


"archana" wrote:
Hi all
I am having application which is using server based timer that is timer
from namespace system.timer.

I am having windows service which i want to run everyday at some fix
time.
In service.cs class i am creating one worker thread and in thread
procedure i am enabling one timer after thread procedure is completed
and in timer's elapsed event i am recalling my function of actual
processing.

But even if i set interval as 24 hours my code is sometime running
continuously.

Can some one tell me why thisis happening. Or can't i start timer in
thread procedure at the end of thread procedure.

Please help me.

thanks in advance,

Feb 20 '06 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

17 posts views Thread by Zvi Danovich | last post: by
7 posts views Thread by Crirus | last post: by
1 post views Thread by archana | last post: by
4 posts views Thread by Daniel | last post: by
2 posts views Thread by archana | last post: by
10 posts views Thread by archana | last post: by
10 posts views Thread by igor | last post: by
reply views Thread by XIAOLAOHU | last post: by

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.