Timer

Timer Class

The Timer class is a static class that manages timer events for a script.

Syntax

public static class Timer

Remarks

The time the event is generated is guaranteed to be no less than the given duration, but may be more depending on system load.

Requirements

Namespace: Sansar.Script
Assembly: Sansar.Script (in Sansar.Script.dll)
Assembly Versions: 1.0.0.0

Members

See Also: Inherited members from object.

Public Methods

static
Cancel (string)
Cancels a repeating timer.
static
Create (TimeSpanAction)
Generates a one time event.
static
Create (TimeSpanTimeSpanAction)
Generates a repeating event with an initial duration and a repeat duration. The event will continue as long as the script is active.
static
Create (TimeSpanTimeSpanActionstring)
Generates a repeating event with an initial duration and a repeat duration. The event will continue as long as the script is active or until Timer.Cancel(string) is called.

Member Details

Cancel Method

Cancels a repeating timer.

Syntax

public static void Cancel (string name)

Parameters

name
Name of the timer to cancel.

Remarks

If no timer with the given name exists, a ArgumentException will be thrown by the invocation.

Requirements

Namespace: Sansar.Script
Assembly: Sansar.Script (in Sansar.Script.dll)
Assembly Versions: 1.0.0.0

Create Method

Generates a one time event.

Syntax

public static void Create (TimeSpan initialDuration, Action handler)

Parameters

initialDuration
The minimum duration to elapse before the event is generated.
handler
The Action to be called when the time has elapsed.

Remarks

To block a coroutine for a period of time, use ScriptBase.Wait(TimeSpan).

Requirements

Namespace: Sansar.Script
Assembly: Sansar.Script (in Sansar.Script.dll)
Assembly Versions: 1.0.0.0

Create Method

Generates a repeating event with an initial duration and a repeat duration. The event will continue as long as the script is active.

Syntax

public static void Create (TimeSpan initialDuration, TimeSpan repeatDuration, Action handler)

Parameters

initialDuration
The minimum duration to elapse before the event is generated.
repeatDuration
After the initial duration, events will be generated at this interval.
handler
The Action to be called when the time has elapsed.

Remarks

At most, one event will be generated per server frame, even if the duration is significantly shorter than the server frame time.

Requirements

Namespace: Sansar.Script
Assembly: Sansar.Script (in Sansar.Script.dll)
Assembly Versions: 1.0.0.0

Create Method

Generates a repeating event with an initial duration and a repeat duration. The event will continue as long as the script is active or until Timer.Cancel(string) is called.

Syntax

public static void Create (TimeSpan initialDuration, TimeSpan repeatDuration, Action handler, string name)

Parameters

initialDuration
The minimum duration to elapse before the event is generated.
repeatDuration
After the initial duration, events will be generated at this interval.
handler
The Action to be called when the time has elapsed.
name
A short string to identify this Timer.

Remarks

At most, one event will be generated per server frame, even if the duration is significantly shorter than the server frame time. Only the first 8 characters of the name are significant. Multiple timers with the same name are allowed. When Timer.Cancel(string) is called the first timer with a matching name is stopped.

Requirements

Namespace: Sansar.Script
Assembly: Sansar.Script (in Sansar.Script.dll)
Assembly Versions: 1.0.0.0


 
Was this article helpful?
0 out of 0 found this helpful
Have more questions? Submit a request

0 Comments

Article is closed for comments.