Example #1
0
    /// <summary>
    /// Executes the actual work method. This is always run on a
    /// named background thread that's been allocated for this
    /// task type.
    /// </summary>
    /// <param name="task"></param>
    private void ExecuteMethod(ScheduledTask task)
    {
        try
        {
            if (task.WorkMethod != null)
            {
                Logging.LogVerbose("Starting execution for task {0}", task.Type);
                task.WorkMethod();
            }
            else
            {
                // Shouldn't ever happen, but be careful
                Logging.LogWarning($"Task {task.Type} did not have a work method.");
            }
        }
        catch (Exception ex)
        {
            Logging.LogError("Exception while executing task {0}: {1}", task.Type, ex.Message);
        }
        finally
        {
            Logging.LogVerbose("Completed execution for task {0}.", task.Type);

            TaskCompleted(task);
            Stopwatch.WriteTotals();
        }
    }