Class TimerFactory
Factory to create Timer objects.
Inheritance
Implements
Inherited Members
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 selected 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 |
Scene | scene | The timer scene. |
Returns
Type | Description |
---|---|
Timer | The new timer. |
Exceptions
Type | Condition |
---|---|
ArgumentException | Already exists a timer with same name. |
ArgumentNullException | If name is null or empty. |
ArgumentException | If already exists a timer with same name. |
CreateTimer(TimeSpan, Action)
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)
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 |
Scene | scene | The timer scene. |
Returns
Type | Description |
---|---|
Timer | The new timer. |
OnAttached()
Attach this service to WaveServices.
Declaration
protected override bool OnAttached()
Returns
Type | Description |
---|---|
bool | True if all is OK. |
Overrides
OnDetach()
Detach this service to WaveServices.
Declaration
protected override void OnDetach()
Overrides
OnLoaded()
Invoked when the object is loaded.
Declaration
protected override void OnLoaded()
Overrides
PauseSceneTimers(Scene)
Pause all scene timers.
Declaration
public void PauseSceneTimers(Scene scene)
Parameters
Type | Name | Description |
---|---|---|
Scene | scene | The scene. |
Exceptions
Type | Condition |
---|---|
ObjectDisposedException | TimerFactory was disposed. |
RemoveAllTimers()
Removes all timers.
Declaration
public void RemoveAllTimers()
Exceptions
Type | Condition |
---|---|
ObjectDisposedException | TimerFactory was disposed. |
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 was 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 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 timer was removed or not. |
Exceptions
Type | Condition |
---|---|
ObjectDisposedException | TimerFactory was disposed. |
ArgumentNullException | Parameter name cannot be null. |
ResumeSceneTimers(Scene)
Resume 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
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 | If 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 | If name is null or empty. |
ArgumentNullException | If action is null. |