Search Results for

    Show / Hide Table of Contents

    Class Switch

    An atomic switch that can be either on or off

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

    Constructors

    | Edit this page View Source

    Switch(bool)

    TBD

    Declaration
    public Switch(bool startAsOn = false)
    Parameters
    Type Name Description
    bool startAsOn

    TBD

    Properties

    | Edit this page View Source

    IsOff

    Gets a value indicating whether this switch is off. No locking.

    Declaration
    public bool IsOff { get; }
    Property Value
    Type Description
    bool

    true if this instance is off; otherwise, false.

    | Edit this page View Source

    IsOn

    Gets a value indicating whether this switch is on. No locking.

    Declaration
    public bool IsOn { get; }
    Property Value
    Type Description
    bool

    true if this instance is on; otherwise, false.

    Methods

    | Edit this page View Source

    IfOff(Action)

    Executes the provided action and returns if the action was executed or not, if the switch is IMMEDIATELY off (i.e. no lock involved)

    Declaration
    public bool IfOff(Action action)
    Parameters
    Type Name Description
    Action action

    The action.

    Returns
    Type Description
    bool

    Return true if the switch was off

    | Edit this page View Source

    IfOn(Action)

    Executes the provided action and returns if the action was executed or not, if the switch is IMMEDIATELY on (i.e. no lock involved)

    Declaration
    public bool IfOn(Action action)
    Parameters
    Type Name Description
    Action action

    The action.

    Returns
    Type Description
    bool

    Return true if the switch was on

    | Edit this page View Source

    Locked(Action)

    TBD

    Declaration
    public void Locked(Action action)
    Parameters
    Type Name Description
    Action action

    TBD

    | Edit this page View Source

    SwitchOff()

    Switches the switch off (if on). Uses locking.

    Declaration
    public bool SwitchOff()
    Returns
    Type Description
    bool

    Returns true if the switch was switched off

    | Edit this page View Source

    SwitchOff(Action)

    Executes the provided action if the lock is on. This is done under a lock so be very careful with longrunning/blocking operations in it. Only executes the action if the switch is on, and switches it off immediately after obtaining the lock. Will switch it back on if the provided action throws an exception.

    Declaration
    public bool SwitchOff(Action action)
    Parameters
    Type Name Description
    Action action

    TBD

    Returns
    Type Description
    bool

    Returns true if the switch was switched off

    | Edit this page View Source

    SwitchOn()

    Switches the switch on (if off). Uses locking.

    Declaration
    public bool SwitchOn()
    Returns
    Type Description
    bool

    Returns true if the switch was switched on

    | Edit this page View Source

    SwitchOn(Action)

    Executes the provided action if the lock is off. This is done under a lock so be very careful with longrunning/blocking operations in it. Only executes the action if the switch is off, and switches it on immediately after obtaining the lock. Will switch it back off if the provided action throws an exception.

    Declaration
    public bool SwitchOn(Action action)
    Parameters
    Type Name Description
    Action action

    TBD

    Returns
    Type Description
    bool

    Returns true if the switch was switched on

    | Edit this page View Source

    TranscendFrom(bool, Action)

    TBD

    Declaration
    protected bool TranscendFrom(bool from, Action action)
    Parameters
    Type Name Description
    bool from

    TBD

    Action action

    TBD

    Returns
    Type Description
    bool

    TBD

    | Edit this page View Source

    WhileOff(Action)

    Executes the provided action and returns if the action was executed or not, if the switch is off, waiting for any pending changes to happen before (locking) Be careful of longrunning or blocking within the provided action as it can lead to deadlocks or bad performance

    Declaration
    public bool WhileOff(Action action)
    Parameters
    Type Name Description
    Action action

    TBD

    Returns
    Type Description
    bool

    TBD

    | Edit this page View Source

    WhileOn(Action)

    Executes the provided action and returns if the action was executed or not, if the switch is on, waiting for any pending changes to happen before (locking) Be careful of longrunning or blocking within the provided action as it can lead to deadlocks or bad performance

    Declaration
    public bool WhileOn(Action action)
    Parameters
    Type Name Description
    Action action

    TBD

    Returns
    Type Description
    bool

    TBD

    Extension Methods

    ObjectExtensions.IsDefaultForType<T>(T)
    ObjectExtensions.AsOption<T>(T)
    Extensions.AsInstanceOf<T>(object)
    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