Run a program repeatedly from another program

  • Thread starter Thread starter Eranga
  • Start date Start date
E

Eranga

I want to add a program to windows which will run at a specified time
period which may be changed by the administrator.What I plan to do is
start the program at windows startup and then within that program check
for the correct time to run. Then when the time is equal to the seted
time another program is called Up to this point I can write code. But
after this I want the earlier program to check repeatedly and run the
second one at this interval.
How can I do this in C#?
Thanks in advance to all your help.
 
Eranga said:
[running a program periodically]

Use a Timer object, and inside the Tick event check whether the
desired time just passed.

Better yet, don't reinvent the wheel - use Scheduled Tasks in Windows
Control Panel.

P.
 
But I can't use windows sheduled tasks because my time interval is not
fixed and can even be somthing like few minutes to several hours.
Also I have figured out a way to check time . My problem i srepeatedly
doing this. Because once it equals the program ends there.
 
So..... basically you want an app to access a file or take an argument
to specify what the 2nd app run time delay is...? k

I would initilize the main app and use a System.Threading.Timer to
recall the 2nd app or preferably thread on that given time delay.

An example of how it works:

public class ....
{
public static void Main()
{
//Fire 20 secs from now, repeating at 25 sec intervals

new Timer(new TimerCallback(OnTimerFireMe), 42, new
TimeSpan(TicksPerSec*20), new TimeSpan(TicksPerSec*25) );
//Continue with other tasks
}

static void OnTimerFireMe(object arg)
{
int x (int)arg;
}
}
 
Back
Top