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

Timers and Services

Hello,

I've written a windows service and so far what it does is browse to a
shared directory on an extranet. Check to see if any files exist in
this folder, if any do, the service downloads, processes and then
uploads a response file back up to a different shared folder.
My Question:
I would like to be able to start this service at 4am every day(I know
the download files won't be there until then)...then I want the service
to check for the files every say 20 mins until say 6am and then stop
chcking for the files until 4am the next day.

Has anyone done something like this and if so how. I have been looking
around but can't seem to find any info on anything like this.

Thanks in Advance.

Nov 17 '05 #1
8 1499
Hi,

Why don't use a scheduled job instead?
Anyway, the answer shoudl be yes, I have a similar deployment, I do not use
itmers, I use FileSystemWatcher instead and it work fine, I create and
initialize the watcher in the onload and the process keep waiting until the
event is received.
The above solution is something you should consider, it's safer, in any
case do not hardcode the times, it could change later on and you would have
to redeploy your solution
cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

<Pa*********@gmail.com> wrote in message
news:11**********************@g49g2000cwa.googlegr oups.com...
Hello,

I've written a windows service and so far what it does is browse to a
shared directory on an extranet. Check to see if any files exist in
this folder, if any do, the service downloads, processes and then
uploads a response file back up to a different shared folder.
My Question:
I would like to be able to start this service at 4am every day(I know
the download files won't be there until then)...then I want the service
to check for the files every say 20 mins until say 6am and then stop
chcking for the files until 4am the next day.

Has anyone done something like this and if so how. I have been looking
around but can't seem to find any info on anything like this.

Thanks in Advance.

Nov 17 '05 #2
Hi,

Why don't use a scheduled job instead?
Anyway, the answer shoudl be yes, I have a similar deployment, I do not use
itmers, I use FileSystemWatcher instead and it work fine, I create and
initialize the watcher in the onload and the process keep waiting until the
event is received.
The above solution is something you should consider, it's safer, in any
case do not hardcode the times, it could change later on and you would have
to redeploy your solution
cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

<Pa*********@gmail.com> wrote in message
news:11**********************@g49g2000cwa.googlegr oups.com...
Hello,

I've written a windows service and so far what it does is browse to a
shared directory on an extranet. Check to see if any files exist in
this folder, if any do, the service downloads, processes and then
uploads a response file back up to a different shared folder.
My Question:
I would like to be able to start this service at 4am every day(I know
the download files won't be there until then)...then I want the service
to check for the files every say 20 mins until say 6am and then stop
chcking for the files until 4am the next day.

Has anyone done something like this and if so how. I have been looking
around but can't seem to find any info on anything like this.

Thanks in Advance.

Nov 17 '05 #3
The windows task sheduler has been disabled and I'm not allowed to use
it.
I can't use the FileSystemWatcher as the folders exist on an extranet
and I can't set up any webfolders on my server.

Sorry I forgot to mention that in the previous post

regards
Paul

Nov 17 '05 #4
The windows task sheduler has been disabled and I'm not allowed to use
it.
I can't use the FileSystemWatcher as the folders exist on an extranet
and I can't set up any webfolders on my server.

Sorry I forgot to mention that in the previous post

regards
Paul

Nov 17 '05 #5
On 31 Aug 2005 06:28:06 -0700, Pa*********@gmail.com wrote:
I would like to be able to start this service at 4am every day(I know
the download files won't be there until then)...then I want the service
to check for the files every say 20 mins until say 6am and then stop
chcking for the files until 4am the next day.


Set your Windows service to start automatically, this way it will be always
running. Then use a System.Threading.Timer for you sheduled jobs. One of
its overloaded constructors takes 2 TimeSpan as parameters. The first one
is the time before the first callback invoke (set it to the time remaining
before 4am) and the second one is the time between 2 callback invokes (set
it to 20 minutes). When the callback method is invoked, check the time: if
it's 6am or later, Dispose your timer to stop it and recreate one for the
next day; if it's before 6am, do whatever you have to do.

Be carefull not to use using a System.Timers.Timer as it seems to be buggy
when used whithin a Windows Service (see
http://support.microsoft.com/default...b;en-us;842793)
Nov 17 '05 #6
On 31 Aug 2005 06:28:06 -0700, Pa*********@gmail.com wrote:
I would like to be able to start this service at 4am every day(I know
the download files won't be there until then)...then I want the service
to check for the files every say 20 mins until say 6am and then stop
chcking for the files until 4am the next day.


Set your Windows service to start automatically, this way it will be always
running. Then use a System.Threading.Timer for you sheduled jobs. One of
its overloaded constructors takes 2 TimeSpan as parameters. The first one
is the time before the first callback invoke (set it to the time remaining
before 4am) and the second one is the time between 2 callback invokes (set
it to 20 minutes). When the callback method is invoked, check the time: if
it's 6am or later, Dispose your timer to stop it and recreate one for the
next day; if it's before 6am, do whatever you have to do.

Be carefull not to use using a System.Timers.Timer as it seems to be buggy
when used whithin a Windows Service (see
http://support.microsoft.com/default...b;en-us;842793)
Nov 17 '05 #7
Thanks Mehdi....

You've given me a great starting point....I'

I'll give it a bash and see how I progress!

Nov 17 '05 #8
Thanks Mehdi....

You've given me a great starting point....I'

I'll give it a bash and see how I progress!

Nov 17 '05 #9

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

Similar topics

0
by: Dmitry Demchuk | last post by:
Hi everybody. Recently I ran into situation with System.Threading.Timer in my ASP.NET application. I reinstalled Windows on one of my servers and got timers stop firing events after while, they...
1
by: Jason | last post by:
Hi all just a quick question. I have a windows service with a "Catalogue" class. I would like to know: if i put two "ServiceTimer" objects in my service 1. Do they run in separate threads...
3
by: Nathan Kovac | last post by:
I have a feeling I am missing something simple, but I just can't find it. Perhaps someone can give me a lead on where to look. I will describe the issue then post my code to the web service. My...
9
by: Mark Rae | last post by:
Hi, I've seen several articles about using System Timers in ASP.NET solutions, specifically setting them up in Global.asax' Application_OnStart event. I'm thinking about the scenario where I...
1
by: james.e.coleman | last post by:
Hello, System.Timers.Timer/System.Threading.Timer do not fire on my development server, yet they work perfectly on the production server. I would appreciate any help on what the cause of this...
1
by: jeff | last post by:
Greetings; Newbie here, please forgive my ignorance of the vb.net threading model. I am developing a windows service which is driven by a variable number of timers. All timers use the same...
2
by: jeff | last post by:
Greetings; Newbie here, please forgive my ignorance of the vb.net threading model. I am developing a windows service which is driven by a variable number of timers. All timers invoke the same...
2
by: cntams | last post by:
All, I have a Windows Service and it has one System.Timers.Timer that fires every 500 milliseconds. Now I have noticed that there's a bug in System.Timers.Timer when it's being used combined with...
5
by: Tony Gravagno | last post by:
I have a class that instantiates two Timer objects that fire at different intervals. My class can be instantiated within a Windows Form or from a Windows Service. Actions performed by one of the...
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?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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...

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.