Search Results for

    Show / Hide Table of Contents

    Class TimerFactory

    Factory for creating Timer objects.

    Inheritance
    object
    IdentifiableObject
    DependencyObject
    AttachableObject
    Service
    UpdatableService
    TimerFactory
    Implements
    IDependencyObject
    Inherited Members
    AttachableObject.AttachableStateChanged
    AttachableObject.IsEnabled
    AttachableObject.State
    AttachableObject.IsLoaded
    AttachableObject.IsAttached
    AttachableObject.IsActivated
    AttachableObject.IsStarted
    AttachableObject.IsDestroyed
    AttachableObject.Destroy()
    DependencyObject.Dependencies
    DependencyObject.OnDependencyRemoved
    IdentifiableObject.Id
    Namespace: Evergine.Framework.Services
    Assembly: Evergine.Framework.dll
    Syntax
    public sealed class TimerFactory : UpdatableService, IDependencyObject

    Methods

    CreateTimer(string, TimeSpan, Action)

    Adds a new timer. If there is already a timer with the specified name, this call will overwrite it.

    Declaration
    public Timer CreateTimer(string name, TimeSpan interval, Action action)
    Parameters
    Type Name Description
    string name

    The name of the new timer.

    TimeSpan interval

    The interval between each timer firing.

    Action action

    The action to execute when the timer fires.

    Returns
    Type Description
    Timer

    The new timer.

    Remarks

    Looped is true by default; use the other overload to change it.

    CreateTimer(string, TimeSpan, Action, bool, Scene)

    Adds a new timer. If there is already a timer with the selected name, this call will overwrite it.

    Declaration
    public Timer CreateTimer(string name, TimeSpan interval, Action action, bool looped, Scene scene = null)
    Parameters
    Type Name Description
    string name

    The name of the new timer.

    TimeSpan interval

    The interval between each timer firing.

    Action action

    The action to execute when the timer fires.

    bool looped

    If set to false, the timer will only fire once.

    Scene scene

    The timer scene.

    Returns
    Type Description
    Timer

    The new timer.

    Exceptions
    Type Condition
    ArgumentException

    A timer with the same name already exists.

    ArgumentNullException

    If the name is null or empty.

    ArgumentException

    If a timer with the same name already exists.

    CreateTimer(TimeSpan, Action)

    Adds a new timer. If a timer with the given name already exists, this call will overwrite it.

    Declaration
    public Timer CreateTimer(TimeSpan interval, Action action)
    Parameters
    Type Name Description
    TimeSpan interval

    The interval between each timer firing.

    Action action

    The action to execute when the timer fires.

    Returns
    Type Description
    Timer

    The new timer.

    Remarks

    Looped is true by default; use the other overload to change it.

    CreateTimer(TimeSpan, Action, bool, Scene)

    Adds a new timer. If there is already a timer with the selected name, this call will overwrite it.

    Declaration
    public Timer CreateTimer(TimeSpan interval, Action action, bool looped, Scene scene = null)
    Parameters
    Type Name Description
    TimeSpan interval

    The interval between each timer firing.

    Action action

    The action to execute when the timer fires.

    bool looped

    If set to false, the timer will only fire one time.

    Scene scene

    The timer's scene.

    Returns
    Type Description
    Timer

    The new timer.

    OnAttached()

    Attaches this service to WaveServices.

    Declaration
    protected override bool OnAttached()
    Returns
    Type Description
    bool

    True if everything is OK.

    Overrides
    Service.OnAttached()

    OnDetach()

    Detaches this service from WaveServices.

    Declaration
    protected override void OnDetach()
    Overrides
    Service.OnDetach()

    OnLoaded()

    Invoked when the object is loaded.

    Declaration
    protected override void OnLoaded()
    Overrides
    Service.OnLoaded()

    PauseSceneTimers(Scene)

    Pauses all scene timers.

    Declaration
    public void PauseSceneTimers(Scene scene)
    Parameters
    Type Name Description
    Scene scene

    The scene.

    Exceptions
    Type Condition
    ObjectDisposedException

    TimerFactory was disposed of.

    RemoveAllTimers()

    Removes all timers.

    Declaration
    public void RemoveAllTimers()
    Exceptions
    Type Condition
    ObjectDisposedException

    TimerFactory was disposed of.

    RemoveSceneTimers(Scene)

    Removes all scene timers.

    Declaration
    public void RemoveSceneTimers(Scene scene)
    Parameters
    Type Name Description
    Scene scene

    The scene.

    Exceptions
    Type Condition
    ObjectDisposedException

    TimerFactory has been disposed.

    RemoveTimer(Timer)

    Removes the timer.

    Declaration
    public bool RemoveTimer(Timer timer)
    Parameters
    Type Name Description
    Timer timer

    The timer.

    Returns
    Type Description
    bool

    Whether the timer was removed or not.

    Exceptions
    Type Condition
    ArgumentNullException

    Timer cannot be null.

    RemoveTimer(string)

    Removes a timer.

    Declaration
    public bool RemoveTimer(string name)
    Parameters
    Type Name Description
    string name

    The name of the timer to remove.

    Returns
    Type Description
    bool

    Whether the timer was removed or not.

    Exceptions
    Type Condition
    ObjectDisposedException

    TimerFactory was disposed.

    ArgumentNullException

    Parameter name cannot be null.

    ResumeSceneTimers(Scene)

    Resumes all scene timers.

    Declaration
    public void ResumeSceneTimers(Scene scene)
    Parameters
    Type Name Description
    Scene scene

    The scene.

    Exceptions
    Type Condition
    ObjectDisposedException

    TimerFactory was disposed.

    Update(TimeSpan)

    Updates this instance.

    Declaration
    public override void Update(TimeSpan gameTime)
    Parameters
    Type Name Description
    TimeSpan gameTime

    The elapsed game time since the last update.

    Overrides
    UpdatableService.Update(TimeSpan)

    UpdateTimer(string, TimeSpan)

    Updates a timer.

    Declaration
    public void UpdateTimer(string name, TimeSpan interval)
    Parameters
    Type Name Description
    string name

    The name of the timer to update.

    TimeSpan interval

    The new interval between each timer firing.

    Exceptions
    Type Condition
    ArgumentNullException

    Thrown if the name is null or empty.

    UpdateTimer(string, TimeSpan, Action)

    Updates a timer.

    Declaration
    public void UpdateTimer(string name, TimeSpan interval, Action action)
    Parameters
    Type Name Description
    string name

    The name of the timer to update.

    TimeSpan interval

    The new interval between each timer firing.

    Action action

    The action to execute when the timer fires.

    Exceptions
    Type Condition
    ArgumentNullException

    Thrown if name is null or empty.

    ArgumentNullException

    Thrown if action is null.

    Implements

    IDependencyObject

    Extension Methods

    ReflectionHelper.GetMemberAssembly(object)
    ReflectionHelper.GetTypeName(object)
    In this article
    Back to top
    Generated by DocFX