protected override void QueueTask(Task task)
{
if ((task.CreationOptions & TaskCreationOptions.LongRunning) == TaskCreationOptions.LongRunning)
{
// Executing a LongRunning task in an ActorTaskScheduler is bad practice, it will potentially
// hang the actor and starve the ThreadPool
// The best thing we can do here is force a rescheduling to at least not execute the task inline.
ScheduleTask(task);
return;
}
// Schedule the task execution, run inline if we are already in the actor context.
if (ActorCell.Current == _actorCell)
{
TryExecuteTask(task);
}
else
{
ScheduleTask(task);
}
}