Example #1
0
        private bool ExecuteTasks()
        {
            bool foundWork = false;

            transactionalStorage.Batch(actions =>
            {
                DatabaseTask task = GetApplicableTask(actions);
                if (task == null)
                {
                    return;
                }

                context.UpdateFoundWork();

                Log.Debug("Executing task: {0}", task);
                foundWork = true;

                context.CancellationToken.ThrowIfCancellationRequested();

                try
                {
                    task.Execute(context);
                }
                catch (Exception e)
                {
                    Log.WarnException(
                        string.Format("Task {0} has failed and was deleted without completing any work", task),
                        e);
                }
            });
            return(foundWork);
        }