private IEnumerator ExecuteTask(Task task)
{
// Execute yieldable actions using the MonoBehavior.
//
// The continuation will execute the task itself
// via TryExecuteTask(). That task action will
// rethrow any exceptions caught during the yieldable
// action invocation and TryExecuteTask() will set
// the final state.
//
// The downside to this approach is that yieldable tasks
// aren't considered running until they have already
// completed because TryExecuteTask() is what sets state.
var yieldableTask = task as YieldableTask;
if(yieldableTask != null)
yield return Fiber.Factory.StartNew(ExecuteYieldableTask(yieldableTask), scheduler);
// Run the action
TryExecuteTask(task);
}