Re-reading your original post, if you are really running as a service,
the interaction becomes a bit more complex... You would probably need to
use .Net Remoting. 

I thought about having a dedicated thread where I would have lots of 
> sleep periods in an infinite loop. After each sleep period, I could 
> compare the current time with the time of the next event that must be 
> fired. The event would have to be fired in X seconds and I would enter

> in a new sleep

This would be a bad design (IMHO).  If you needed to go with this type
of implementation, you should use the Timer class, and could wake up
periodically, you could probably even determine how long you wanted to
wait between "ticks" of the timer and wake up more closely to what you
need.

If you are running as a console app, you could simply pass it the
command line parameters that you would as if you are running it.  The
only gotcha is that you would by default run as a different user, so you
may want/need to configure the app to run as a specific user.

-----Original Message-----
From: Discussion of advanced .NET topics.
[mailto:[EMAIL PROTECTED] On Behalf Of Eddie Lascu
Sent: Wednesday, September 27, 2006 4:34 PM
To: ADVANCED-DOTNET@DISCUSS.DEVELOP.COM
Subject: Re: [ADVANCED-DOTNET] Triggering events at precise moments of
the day

They don't have COM Interfaces (my app is a plain C# win service). Could
you elaborate on your second solution?
Thanks.

-----Original Message-----
From: Discussion of advanced .NET topics.
[mailto:[EMAIL PROTECTED] Behalf Of John Bergman
Sent: Wednesday, September 27, 2006 5:30 PM
To: ADVANCED-DOTNET@DISCUSS.DEVELOP.COM
Subject: Re: [ADVANCED-DOTNET] Triggering events at precise moments of
the day


You could use VBScript to interact with them if they have COM
interfaces, or you can start an Executable with the scheduler itself.

-----Original Message-----
From: Discussion of advanced .NET topics.
[mailto:[EMAIL PROTECTED] On Behalf Of Eddie Lascu
Sent: Wednesday, September 27, 2006 4:28 PM
To: ADVANCED-DOTNET@DISCUSS.DEVELOP.COM
Subject: Re: [ADVANCED-DOTNET] Triggering events at precise moments of
the day

How would that interact with all the structures and objects that are
created in my app?

-----Original Message-----
From: Discussion of advanced .NET topics.
[mailto:[EMAIL PROTECTED] Behalf Of gregory young
Sent: Wednesday, September 27, 2006 5:25 PM
To: ADVANCED-DOTNET@DISCUSS.DEVELOP.COM
Subject: Re: [ADVANCED-DOTNET] Triggering events at precise moments of
the day


Well depending what you are doing I would prbably just use windows
scheduler.

On 9/27/06, Eddie Lascu <[EMAIL PROTECTED]> wrote:
> Hello experts,
>
> I need to call a method in my console app/win service at precise 
> moments
of
> the day. When I say precise I mean +/- a few seconds. The number of 
> events triggered and the time of the day when they should be triggered

> is
variable.
> If only one method call must be performed, then it should always be 
> approximately at the same time of the day, say midnight. If two events

> are to be fired, they should be say 12 hours apart, noon and midnight,

> and so on. The configuration part I can handle. I need some ideas on 
> how to
trigger
> the events.
> I thought about having a dedicated thread where I would have lots of 
> sleep periods in an infinite loop. After each sleep period, I could 
> compare the current time with the time of the next event that must be 
> fired. The event would have to be fired in X seconds and I would enter

> in a new sleep
period
> for X/2 seconds. Eventually, the difference between the current time 
> and
the
> time of the next event would become smaller that an acceptable delta, 
> at which moment I would fire the event and would enter in a new sleep
period.
> This way the events would always be fired at approximately the same 
> times
of
> the day, and I wouldn't have to worry about the moment when the 
> application/win service was started.
> I am not particularly proud of this solution as it seems kind of 
> empiric, but I just couldn't think of anything else.
> Can you gals and guys come up with a more elegant and reliable
approach?
>
> TIA,
> Eddie
>
> ===================================
> This list is hosted by DevelopMentor(r)  http://www.develop.com
>
> View archives and manage your subscription(s) at
http://discuss.develop.com
>


--
If knowledge can create problems, it is not through ignorance that we
can solve them.

Isaac Asimov

===================================
This list is hosted by DevelopMentor(r)  http://www.develop.com

View archives and manage your subscription(s) at
http://discuss.develop.com

===================================
This list is hosted by DevelopMentor(r)  http://www.develop.com

View archives and manage your subscription(s) at
http://discuss.develop.com

===================================
This list is hosted by DevelopMentor.  http://www.develop.com

View archives and manage your subscription(s) at
http://discuss.develop.com

===================================
This list is hosted by DevelopMentor(r)  http://www.develop.com

View archives and manage your subscription(s) at
http://discuss.develop.com

===================================
This list is hosted by DevelopMentorĀ®  http://www.develop.com

View archives and manage your subscription(s) at http://discuss.develop.com

Reply via email to