Search Results for

    Show / Hide Table of Contents

    Class GracefulStopSupport

    GracefulStop extensions.

    Inheritance
    object
    GracefulStopSupport
    Inherited Members
    object.Equals(object)
    object.Equals(object, object)
    object.GetHashCode()
    object.GetType()
    object.MemberwiseClone()
    object.ReferenceEquals(object, object)
    object.ToString()
    Namespace: Akka.Actor
    Assembly: Akka.dll
    Syntax
    public static class GracefulStopSupport

    Methods

    | Edit this page View Source

    GracefulStop(IActorRef, TimeSpan)

    Returns a Task that will be completed with success when existing messages of the target actor have been processed and the actor has been terminated.

    Useful when you need to wait for termination or compose ordered termination of several actors, which should only be done outside of the ActorSystem as blocking inside ActorBase is discouraged.

    IMPORTANT: the actor being terminated and its supervisor being informed of the availability of the deceased actor's name are two distinct operations, which do not obey any reliable ordering.

    If the target actor isn't terminated within the timeout the Task is completed with failure.

    If you want to invoke specialized stopping logic on your target actor instead of PoisonPill, you can pass your stop command as a parameter:

    GracefulStop(someChild, timeout, MyStopGracefullyMessage).ContinueWith(r => {
        // Do something after someChild starts being stopped.
    });
    Declaration
    public static Task<bool> GracefulStop(this IActorRef target, TimeSpan timeout)
    Parameters
    Type Name Description
    IActorRef target

    The actor to be terminated.

    TimeSpan timeout

    The amount of time we're going to wait for the actor to terminate.

    Returns
    Type Description
    Task<bool>

    A Task that will return true if the target shuts down within timeout.

    | Edit this page View Source

    GracefulStop(IActorRef, TimeSpan, object)

    Returns a Task that will be completed with success when existing messages of the target actor have been processed and the actor has been terminated.

    Useful when you need to wait for termination or compose ordered termination of several actors, which should only be done outside of the ActorSystem as blocking inside ActorBase is discouraged.

    IMPORTANT: the actor being terminated and its supervisor being informed of the availability of the deceased actor's name are two distinct operations, which do not obey any reliable ordering.

    If the target actor isn't terminated within the timeout the Task is completed with failure.

    If you want to invoke specialized stopping logic on your target actor instead of PoisonPill, you can pass your stop command as a parameter:

    GracefulStop(someChild, timeout, MyStopGracefullyMessage).ContinueWith(r => {
        // Do something after someChild starts being stopped.
    });
    Declaration
    public static Task<bool> GracefulStop(this IActorRef target, TimeSpan timeout, object stopMessage)
    Parameters
    Type Name Description
    IActorRef target

    The actor to be terminated.

    TimeSpan timeout

    The amount of time we're going to wait for the actor to terminate.

    object stopMessage

    A custom message to use to shutdown target - by default the other overload uses PoisonPill.

    Returns
    Type Description
    Task<bool>

    A Task that will return true if the target shuts down within timeout

    Exceptions
    Type Condition
    TaskCanceledException

    This exception is thrown if the underlying task is Canceled.

    In this article
    • githubEdit this page
    • View Source
    Back to top
    Contribute
    • Project Chat
    • Discussion Forum
    • Source Code
    Support
    • Akka.NET Support Plans
    • Akka.NET Observability Tools
    • Akka.NET Training & Consulting
    Maintained By
    • Petabridge - The Akka.NET Company
    • Learn Akka.NET