int Ns_ScheduleDaily( Ns_SchedProc *proc, void *context, int flags, int hour, int minute, Ns_SchedProc *cleanup );
The Ns_ScheduleDaily function schedules the procedure (proc
) to be run once a day at the specified time (hour
and minute
).
The proc
is the scheduled procedure that will be run once a day. It is a function that takes the context and id of the schedule procedure. The id
can be used in the Ns_UnscheduleProc procedure to stop the procedure from being called again.
typedef void (Ns_SchedProc) (void *context, int id);
The context
is the context to pass to the scheduled procedure.
The possible flags are NS_SCHED_ONCE and NS_SCHED_THREAD. If you specify NS_SCHED_ONCE, the procedure will only be executed once on the specified day and time, and it will not be re-scheduled to execute again the next day. By default, the procedure is re-scheduled after every time it is executed.
If you specify NS_SCHED_THREAD, the procedure will run detached in a separate thread instead of using the one scheduled procedure thread used by all other scheduled procedures. You should use NS_SCHED_THREAD if the procedure will not return immediately. Note that if you use NS_SCHED_THREAD, and the procedure is still active the next time to run occurs, the next run is skipped instead of just delayed.
The hour
can be an integer from 0 to 23, and the minute
an integer from 0 to 59.
The cleanup
procedure will be run once when the proc
procedure is unscheduled.
Run a procedure (MyProc) once in its own thread at 2:30 a.m.:
Ns_ScheduleDaily(myProc, myCtx, NS_SCHED_ONCE | NS_SCHED_THREAD, 2, 30, NULL)