コード例 #1
0
    protected override bool TryExecuteTaskInline(Task task, bool taskWasPreviouslyQueued) => false; // executing already inline through actors queue

    public static void RunTask <T>(Func <Task> asyncHandler, IMailbox mailbox, Actor actor)
    {
        mailbox.SuspendExceptFor(Mailbox.Task, typeof(IAsyncMessage));
        Task <Task> .Factory.StartNew(asyncHandler, CancellationToken.None, TaskCreationOptions.None, mailbox.TaskScheduler)
        .Unwrap()
        .ContinueWith(parent =>
        {
            var exception = ExceptionFor(parent);
            if (exception == null)
            {
                mailbox.Resume(Mailbox.Task);
            }
            else
            {
                actor.Stage.HandleFailureOf(new StageSupervisedActor <T>(actor, exception));
            }
        }, mailbox.TaskScheduler);
    }