issue in server based timer/

A

archana

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,
 
A

archana

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.
 
G

Guest

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top