473,385 Members | 1,356 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,385 software developers and data experts.

Need help writing a simple scheduler

Hi all,

I'm trying to write a simple Windows Service that will "do something" at a
given time, for example call a method at 5pm.
What's the easiest way to schedule a task like that in C# ? All I can think
of right now is checking the system clock every minute or so until it hits
5pm, but I feel there has to be a better way.

Note, please don't offer Windows Scheduler. I'm trying to learn here ;)

Thanks in advance,

-Oleg.
Nov 15 '05 #1
3 14363
Hi Oleg,

You may like to check the sample in the link below -
http://www.codeproject.com/csharp/scheduler.asp

Regards,
Aravind C
"Oleg Ogurok" <ol**@ogurok.com.ihatespammers.ireallydo.co> wrote in message
news:10*************@corp.supernews.com...
Hi all,

I'm trying to write a simple Windows Service that will "do something" at a
given time, for example call a method at 5pm.
What's the easiest way to schedule a task like that in C# ? All I can think of right now is checking the system clock every minute or so until it hits
5pm, but I feel there has to be a better way.

Note, please don't offer Windows Scheduler. I'm trying to learn here ;)

Thanks in advance,

-Oleg.

Nov 15 '05 #2
1) You can use the Timer class.

When the system starts, check how much time is left until 5pm and set the
timer to fire an event after the calculated interval.

Then, every time the event is fired, configure appropriately the Timer using
the above attitued when you finish processing

2) Your proposal is all right as well, but remember, that you need to start
a new thread in the OnStart method of the system service to perform looping
and checking the time.

--
Cezary Nolewajka
mailto:c.*********************@no-sp-am-eh-mail.com
remove all "no-sp-am-eh"s to reply
"Oleg Ogurok" <ol**@ogurok.com.ihatespammers.ireallydo.co> wrote in message
news:10*************@corp.supernews.com...
Hi all,

I'm trying to write a simple Windows Service that will "do something" at a
given time, for example call a method at 5pm.
What's the easiest way to schedule a task like that in C# ? All I can think of right now is checking the system clock every minute or so until it hits
5pm, but I feel there has to be a better way.

Note, please don't offer Windows Scheduler. I'm trying to learn here ;)

Thanks in advance,

-Oleg.


Nov 15 '05 #3
Oleg,
I would recommend a System.Timers.Timer also, as Cezary did.

For a discussion of the three timers available in .NET see:
http://msdn.microsoft.com/msdnmag/is...T/default.aspx

Hope this helps
Jay

"Oleg Ogurok" <ol**@ogurok.com.ihatespammers.ireallydo.co> wrote in message
news:10*************@corp.supernews.com...
Hi all,

I'm trying to write a simple Windows Service that will "do something" at a
given time, for example call a method at 5pm.
What's the easiest way to schedule a task like that in C# ? All I can think of right now is checking the system clock every minute or so until it hits
5pm, but I feel there has to be a better way.

Note, please don't offer Windows Scheduler. I'm trying to learn here ;)

Thanks in advance,

-Oleg.

Nov 15 '05 #4

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

Similar topics

385
by: Xah Lee | last post by:
Jargons of Info Tech industry (A Love of Jargons) Xah Lee, 2002 Feb People in the computing field like to spur the use of spurious jargons. The less educated they are, the more they like...
1
by: Neil Ginsberg | last post by:
I am having trouble using Windows Scheduler with an A2K database that has a password. The password is a db password, not a user-level security password. I have a routine I am looking for Scheduler...
21
by: ashish | last post by:
i need to write a tsr in c language which asks for the login id and password before the windows appear. if anyone could advise of any links which might prove fruitful or anysuggestions.. thanking...
2
by: Kevin | last post by:
Hi, I am looking for a Task Scheduler with source code that has the following features: - Must perform all of the same functions as the Windows Task Scheduler - Must be able to run COM...
1
by: giesss | last post by:
I have been searching for a way to call a third party emailer to send mass emails from MS Access. Outlook thinks it is spam and asks the user to verify every email. I need to send many emails with an...
0
by: asil2003 | last post by:
Learn how to develop an application protocol as well as build an application over UNIX (Linux) socket. 2. Project Description: Build an on-line personal schedule manager In this programming...
2
by: yamca | last post by:
I want to write a task scheduler. But i cant make the logic between the scheduler and tasks. For example a have an external process which can add and delete tasks from scheduler. Every task has...
1
by: keelerpd | last post by:
Hey all, I am new to Perl.....we are talking in the "hrs in experience". I have an occasion to write out to a text file on the machine from a perlscript file. I have multiple steps being issued...
1
by: =?Utf-8?B?YXVzdGlyb2I=?= | last post by:
Hi, While I realise that this may not be a very nice solution architecturally, I kick off a Scheduler in an ASP.NET 2.0 webservice in Application_Start() which is supposed to call a stored proc...
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: 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:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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...

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.