Exemple #1
0
        private void ExecuteJob(ICronJob job)
        {
            using (var log = _logFactory.GetLogForJob(job))
            {
                var context = new CronContext(job, log);

                log.Info(() => String.Format("Executing job: {0}", job));

                // This inner try-catch serves to report ICronJob failures to the ILog.
                // Such exceptions are expected, and are thus handled seperately.
                try
                {
                    job.Initialize(context);
                    job.Execute();
                }
                catch (Exception exception)
                {
                    log.Error(() => String.Format("The job \"{0}\" threw an unhandled exception.", job),
                              () => exception);
                }
            }
        }
Exemple #2
0
        private void ExecuteJob(ICronJob job)
        {
            using (var log = _logFactory.GetLogForJob(job))
            {
                var context = new CronContext(job, log);

                log.Info(() => String.Format("Executing job: {0}", job));

                // This inner try-catch serves to report ICronJob failures to the ILog.
                // Such exceptions are expected, and are thus handled seperately.
                try
                {
                    job.Initialize(context);
                    InvokeJobStarted(new JobEventArgs(job));
                    job.Execute();
                    InvokeJobFinished(new JobEventArgs(job));
                }
                catch (Exception exception)
                {
                    log.Error(() => String.Format("The job \"{0}\" threw an unhandled exception.", job),
                              () => exception);
                }
            }
        }