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

Timers

I want to Start a process in a Service
once a Week

Whats the Best Way to Handle this

I have A completed Service with Threading Manager
But I dont know the Best way to Start a Process
on a Given Day...only once on That Day if Success
if Failure ..then Try Again

Tks
DaveL
Jun 27 '08 #1
6 3080
On Sat, 14 Jun 2008 10:44:28 -0700, daveL <ve***********@yahoo.comwrote:
I want to Start a process in a Service
once a Week

Whats the Best Way to Handle this
Why not use a Timer class? System.Timers.Timer or System.Threading.Timer
would seem appropriate for a service.

Pete
Jun 27 '08 #2
I am Using System.Timer
Where im having a problem is
Iim not sure how to
go about having this fire once a week and only run once
on a specified Day

Any advice
Thanks DaveL
"Peter Duniho" <Np*********@nnowslpianmk.comwrote in message
news:op***************@petes-computer.local...
On Sat, 14 Jun 2008 10:44:28 -0700, daveL <ve***********@yahoo.comwrote:
>I want to Start a process in a Service
once a Week

Whats the Best Way to Handle this

Why not use a Timer class? System.Timers.Timer or System.Threading.Timer
would seem appropriate for a service.

Pete

Jun 27 '08 #3
On Sat, 14 Jun 2008 17:17:09 -0700, daveL <ve***********@yahoo.comwrote:
I am Using System.Timer
There's no such class. Do you mean System.Timers.Timer?
Where im having a problem is
Iim not sure how to
go about having this fire once a week and only run once
on a specified Day
What problem are you having? What about the goal aren't you sure about?
Are you having trouble calculating the number of milliseconds in a week?
Is your code for some reason running the timer elapsed handler more than
once in a day, in spite of having set the interval to a week?

Your question is extremely vague. You really will need to state your
question more clearly to get a useful reply.

Pete
Jun 27 '08 #4
Im not explaining myself well , because im unsure how to approach this

so do i set the interval to x amount of milliseconds based on milliseconds
in a 24 hour period
then check if its the day i want

also if time to run is involved do i set the timer to lets say hourly and
how to make it precise on the time required to run

the thread is running perfect i just dont have it running like i need
yet....

i hope the above helps..
Thanks DaveL

much appriciated
"daveL" <ve***********@yahoo.comwrote in message
news:33****************@flpi150.ffdc.sbc.com...
>I am Using System.Timer
Where im having a problem is
Iim not sure how to
go about having this fire once a week and only run once
on a specified Day

Any advice
Thanks DaveL
"Peter Duniho" <Np*********@nnowslpianmk.comwrote in message
news:op***************@petes-computer.local...
>On Sat, 14 Jun 2008 10:44:28 -0700, daveL <ve***********@yahoo.com>
wrote:
>>I want to Start a process in a Service
once a Week

Whats the Best Way to Handle this

Why not use a Timer class? System.Timers.Timer or System.Threading.Timer
would seem appropriate for a service.

Pete


Jun 27 '08 #5
On Sat, 14 Jun 2008 17:36:41 -0700, daveL <ve***********@yahoo.comwrote:
Im not explaining myself well , because im unsure how to approach this

so do i set the interval to x amount of milliseconds based on
milliseconds
in a 24 hour period
then check if its the day i want
You could. But why not just set the interval to the number of
milliseconds in a week?
also if time to run is involved do i set the timer to lets say hourly and
how to make it precise on the time required to run
How precise do you need it to be?

It seems to me your best bet is to determine the exact time in the future
you want the timer to execute, calculate the difference between that exact
time and "now", and then use the result of that as the timer delay for a
one-shot timer.

Elapsed time calculation might look like:

DateTime dtEvent = /* initialized to some specific date/time */
TimeSpan tsDelay = dtEvent - DateTime.Now;

Then the milliseconds are "tsDelay.TotalMilliseconds". Assuming you're
using a timer that requires setting in milliseconds, set this for the
elapsed time for the timer and start the timer. It will fire when the
elapsed time has expired. (Obviously for a timer class that accepts a
TimeSpan value, you don't need to use the TotalMilliseconds property to
convert to milliseconds :) ).

Each timer class has a slightly different syntax for configuring it as a
one-shot timer, so without knowing what class you're using, it's not
possible to say for sure what you would want to do. But, for example, the
System.Timers.Timer class has an AutoReset property which, when set to
false, causes the timer to fire just once. It won't fire again until you
specifically start it again.

Finally, a week is a long time. Obviously you may want to include some
means of re-enabling the timer in case your process exits and is restarted
before the timer fires. This is just a special case of the above
calculation, where the "specific date/time" is the same as it was before,
but of course DateTime.Now returns a new value. :)
the thread is running perfect i just dont have it running like i need
yet....
No offense intended, but that sentence seems self-contradictory. :)

Pete
Jun 27 '08 #6
about my last sentence....lol I know...
what i meant was i just set the timer to 30 seconds while testing the
threading
so i can make sure all is running correctly, stored procs , processing,
updating etc

now i need to re think the timers on running the way they need to run

1 time once a week at a given time....

I thank you very much for your time and effort
DaveP

"Peter Duniho" <Np*********@nnowslpianmk.comwrote in message
news:op***************@petes-computer.local...
On Sat, 14 Jun 2008 17:36:41 -0700, daveL <ve***********@yahoo.comwrote:
Im not explaining myself well , because im unsure how to approach this

so do i set the interval to x amount of milliseconds based on
milliseconds
in a 24 hour period
then check if its the day i want
You could. But why not just set the interval to the number of
milliseconds in a week?
also if time to run is involved do i set the timer to lets say hourly and
how to make it precise on the time required to run
How precise do you need it to be?

It seems to me your best bet is to determine the exact time in the future
you want the timer to execute, calculate the difference between that exact
time and "now", and then use the result of that as the timer delay for a
one-shot timer.

Elapsed time calculation might look like:

DateTime dtEvent = /* initialized to some specific date/time */
TimeSpan tsDelay = dtEvent - DateTime.Now;

Then the milliseconds are "tsDelay.TotalMilliseconds". Assuming you're
using a timer that requires setting in milliseconds, set this for the
elapsed time for the timer and start the timer. It will fire when the
elapsed time has expired. (Obviously for a timer class that accepts a
TimeSpan value, you don't need to use the TotalMilliseconds property to
convert to milliseconds :) ).

Each timer class has a slightly different syntax for configuring it as a
one-shot timer, so without knowing what class you're using, it's not
possible to say for sure what you would want to do. But, for example, the
System.Timers.Timer class has an AutoReset property which, when set to
false, causes the timer to fire just once. It won't fire again until you
specifically start it again.

Finally, a week is a long time. Obviously you may want to include some
means of re-enabling the timer in case your process exits and is restarted
before the timer fires. This is just a special case of the above
calculation, where the "specific date/time" is the same as it was before,
but of course DateTime.Now returns a new value. :)
the thread is running perfect i just dont have it running like i need
yet....
No offense intended, but that sentence seems self-contradictory. :)

Pete
Jun 27 '08 #7

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

Similar topics

1
by: GDumencu | last post by:
I have a C# program that have to run all the time. For some reasons I cannot make it a service. This program has 3 timers and by time to time ( days or weeks) one of them stops. Some times, starts...
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...
0
by: Cider123 | last post by:
I was originally using: System.Windows.Forms.Timer It started to lock my Window Service up, so I went to the next evolution: System.Threading.Timer All was good. I was using it to send...
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...
3
by: Jeff Greenland | last post by:
Hello everyone, I am having problems with Timers in a web application. They just seem to stop running after 15 minutes or so. My web application is set up like this: When a user hits a...
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...
10
by: WhiteSocksGuy | last post by:
Help! I am new to Visual Basic .Net (version 2002) and I am trying to get a System.Timers.Timer to work for me to display a splash screen for about two seconds and then load the main form. I have...
5
by: Michael C# | last post by:
Hi all, I set up a System.Timers.Time in my app. The code basically just updates the screen, but since the processing performed is so CPU-intensive, I wanted to make sure it gets updated...
1
by: | last post by:
Frustrated.. (I have seen other posts regarding this problem with no resolution..) I am using dotnet 1.1 with latest SP on a Win2KP box (actually 2 boxes), have even run the service on WinXP SP2...
1
by: Jonathan Woods | last post by:
Hi there, I have three methods these need to execute at every interval time. I would like to know which option is better? Option A) Three System.Timers.Timer objects these execute each...
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: 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: 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...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

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.