public static void ExecuteTask(BackgroundTask task) { for (var i = 0; i < 10; i++) { using (var session = _documentStore.OpenSession()) { switch (task.Run(session)) { case true: case false: return; case null: break; } } } }
public static void ExcuteLater(BackgroundTask task) { tasksToExecute.Value.Add(task); }