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 (TimeSpan, Action) : IEventSubscription
Generates a one time event.
static
Create (TimeSpan, Action, bool) : IEventSubscription
Generates a one time event.
static
Create (TimeSpan, TimeSpan, Action) : IEventSubscription
Generates a repeating event with an initial duration and a repeat duration.
static
Create (TimeSpan, TimeSpan, Action, string)
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

[System.Obsolete("Named timers are deprecated. Use the IEventSubscription returned from Timer.Create to cancel a timer.", false)]
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 IEventSubscription 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.

Returns

Documentation for this section has not yet been entered.

Remarks

Documentation for this section has not yet been entered.

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 IEventSubscription Create (TimeSpan initialDuration, Action handler, bool persistent)

Parameters

initialDuration
The minimum duration to elapse before the event is generated.
handler
The Action to be called when the time has elapsed.
persistent
Set to true to continue generating events, false to stop after the first one

Returns

Documentation for this section has not yet been entered.

Remarks

Documentation for this section has not yet been entered.

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.

Syntax

public static IEventSubscription 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.

Returns

Documentation for this section has not yet been entered.

Remarks

 

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

[System.Obsolete("Named timers are deprecated. Use the IEventSubscription returned from Timer.Create to cancel a timer.", false)]
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.