473,378 Members | 1,346 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,378 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 1399
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: B Moor | last post by:
SServer PC: Win SBS 2003 with 2.6 GHz processor and 1GB RAM SQL Server 2000 v 2000.8.00.76 (sp3) MS Office 2k3 MSJet ms04-014 (latest ost sp8) MDAC v2.8 RTM ADO 2.1 vb6.exe / ADO 2.0 I...
17
by: Zvi Danovich | last post by:
Hi, I am a newby in ASP.NET, and till now wrote only simple "classic" WEB-sites. But - the time came, and now I need that: 1. Server will "listen" for some events on its local machine 2....
7
by: Crirus | last post by:
I have a server and I need to implement a automate process that occur at a certain interval, based on current time. I need to "tick" at every 10 minutes or (another version) when time is 30 minutes...
1
by: archana | last post by:
Hi all, I want to clear one doubt which i am facing regarding timer. Suppose i have one timer in which i am generating some files. and interval of my timer is say 5 min. Say suppose at...
4
by: Daniel | last post by:
Hey guys Here is what i want to do. I have made a multiplayer game that needs to when more than one player is ready start a countdown that the clients can see, so players can still join in this...
2
by: archana | last post by:
Hi all, I am having one confusion regarding windows based timer. I read somewhere that 'Be careful with stopping, because stopped timers are disabled and are subject to garbage collection....
10
by: archana | last post by:
Hi all, can anyone tell me how server based timer in .net works? Which one of either system.timers.timer, system.threading.timer is better for use in windows service. How worker thread call...
10
by: igor | last post by:
I have recently discovered that the system.Timers.Timer from.Net Framework v1.1 is not reliable when used on Windows 2003 server. When incorporated into a Windows Service, the timer_elapsed event...
8
by: Ollie Riches | last post by:
I'm looking into a production issue related to a windows service and System.Timers.Timer. The background is the windows service uses a System.Timers.Timer to periodically poll a directory location...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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: 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...

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.