I have an NCron service that is running on a set interval. I want to pass a variable to the job, but I haven't been able to figure out how. I also didn't see any information in the NCon Wiki. Is it possible to pass any arguments to the NCron service?
If your not familiar with NCron or need more information: http://code.google.com/p/ncron/
service.At(setting.Interval).Run(setting.ClassInfo);
Assuming the value you want to pass to the job is something you have available while registering the jobs with the scheduler (eg command line parameters), you could do something like this:
static void ServiceSetup(SchedulingService service)
{
service.Hourly().Run(() => new MyJob("literal"));
service.Daily().Run(() => new MyJob(_field));
}
Using sexy lambda syntax, you have just defined two one-line functions each instantiating the same class of job using different constructor parameters.
Alternatively, you could let an IoC container instantiate your jobs with whatever constructor arguments and/or services they require. If you have no idea what I am talking about now, you probably want to stick to the first suggestion, though :)