예제 #1
0
        private static void LongRunningJobMethod(JobRunContext jobContext, string arg0, int arg1)
        {
            _callCount++;
            var timeService = jobContext.App.TimeService;
            var startTime   = timeService.UtcNow;
            var endTime     = startTime.AddMinutes(10);
            var count       = 0;

            while (timeService.UtcNow < endTime)
            {
                Thread.Sleep(1);
                jobContext.UpdateProgress(count++, "Continuing, count: " + count);
            }
            jobContext.UpdateProgress(100, "Completed successfully");
        }
예제 #2
0
 public static void JobMethod(JobRunContext jobContext, int failCount, string stringArg, List <string> listArg)
 {
     _callCount++;
     // Check string arg and listPrm are deserialized correctly
     Util.Check(!string.IsNullOrEmpty(stringArg), "StringArg is not deserialized.");
     Util.Check(listArg != null && listArg.Count > 1, "Failed to deserialize list argument.");
     // Throw if we have not reached failCount; note that AttemptNumber is 1-based
     if (jobContext.AttemptNumber <= failCount)
     {
         Util.Throw("Job run failed; target fail count: {0}, attempt number: {0}.", failCount, jobContext.AttemptNumber);
     }
     // for single successful run of ExecuteWithRetriesNoWait the UpdateProgress call is ignored
     // - jobRun record is not created
     jobContext.UpdateProgress(100, SuccessMessage);
 }