SwiftlyS2

ISchedulerService

Interface ISchedulerService

Namespace: SwiftlyS2.Shared.Scheduler

Assembly: SwiftlyS2.CS2.dll

public interface ISchedulerService

Methods

Delay(int, Action)

Add a delayed task to the scheduler.

CancellationTokenSource Delay(int delayTick, Action task)
Parameters
  • delayTick int — The delay of the timer in ticks.
  • task Action — The task to execute.
Returns

DelayAndRepeat(int, int, Action)

Add a delayed and repeated task to the scheduler.

CancellationTokenSource DelayAndRepeat(int delayTick, int periodTick, Action task)
Parameters
  • delayTick int — The delay of the timer in ticks.
  • periodTick int — The period of the timer in ticks.
  • task Action — The task to execute.
Returns

DelayAndRepeatBySeconds(float, float, Action)

Add a delayed and repeated task to the scheduler.

The timing is based on game tick, which means it becomes inaccurate when intervals approachs 1 tick (approximately 15ms).

CancellationTokenSource DelayAndRepeatBySeconds(float delaySeconds, float periodSeconds, Action task)
Parameters
  • delaySeconds float — The delay of the timer in seconds.
  • periodSeconds float — The period of the timer in seconds.
  • task Action — The task to execute.
Returns

DelayBySeconds(float, Action)

Add a delayed task to the scheduler.

The timing is based on game tick, which means it becomes inaccurate when intervals approachs 1 tick (approximately 15ms).

CancellationTokenSource DelayBySeconds(float delaySeconds, Action task)
Parameters
  • delaySeconds float — The delay of the timer in seconds.
  • task Action — The task to execute.
Returns

NextTick(Action)

Add a task to be executed on the next tick.

void NextTick(Action task)
Parameters
  • task Action — The task to execute.

NextTick(Func<Task?>)

Never use this! you should never calls async callback in next tick, because async callback have chance to run in async context, which breaks the the synchronization safety this function gives.

[Obsolete("Please remove the async modifier on your callback for safety reason. See comments for more details.")]
void NextTick(Func<Task?> task)
Parameters
Exceptions

NextTick<T>(Func<Task<T?>>)

Never use this! you should never calls async callback in next tick, because async callback have chance to run in async context, which breaks the the synchronization safety this function gives.

[Obsolete("Please remove the async modifier on your callback for safety reason. See comments for more details.")]
void NextTick<T>(Func<Task<T?>> task)
Parameters
Type Parameters
  • T
Exceptions

NextTickAsync(Action)

Add a task to be executed on the next tick asynchronously.

Task NextTickAsync(Action task)
Parameters
  • task Action — The task to execute.
Returns

NextTickAsync(Func<Task?>)

Never use this! you should never calls async callback in next tick, because async callback have chance to run in async context, which breaks the the synchronization safety this function gives.

[Obsolete("Please remove the async modifier on your callback for safety reason. See comments for more details.")]
void NextTickAsync(Func<Task?> task)
Parameters
Exceptions

NextTickAsync<T>(Func<Task<T?>>)

Never use this! you should never calls async callback in next tick, because async callback have chance to run in async context, which breaks the the synchronization safety this function gives.

[Obsolete("Please remove the async modifier on your callback for safety reason. See comments for more details.")]
void NextTickAsync<T>(Func<Task<T?>> task)
Parameters
Type Parameters
  • T
Exceptions

NextTickAsync<T>(Func<T>)

Add a task to be executed on the next tick asynchronously.

Task<T> NextTickAsync<T>(Func<T> task)
Parameters
  • task Func<T> — The task to execute.
Returns
Type Parameters
  • T

NextWorldUpdate(Action)

Add a task to be executed on the next world update.

void NextWorldUpdate(Action task)
Parameters
  • task Action — The task to execute.

NextWorldUpdate(Func<Task?>)

Never use this! you should never calls async callback in next world update, because async callback have chance to run in async context, which breaks the the synchronization safety this function gives.

[Obsolete("Please remove the async modifier on your callback for safety reason. See comments for more details.")]
void NextWorldUpdate(Func<Task?> task)
Parameters
Exceptions

NextWorldUpdate<T>(Func<Task<T?>>)

Never use this! you should never calls async callback in next world update, because async callback have chance to run in async context, which breaks the the synchronization safety this function gives.

[Obsolete("Please remove the async modifier on your callback for safety reason. See comments for more details.")]
void NextWorldUpdate<T>(Func<Task<T?>> task)
Parameters
Type Parameters
  • T
Exceptions

NextWorldUpdateAsync(Action)

Add a task to be executed on the next world update asynchronously.

Task NextWorldUpdateAsync(Action task)
Parameters
  • task Action — The task to execute.
Returns

NextWorldUpdateAsync(Func<Task?>)

Never use this! you should never calls async callback in next world update, because async callback have chance to run in async context, which breaks the the synchronization safety this function gives.

[Obsolete("Please remove the async modifier on your callback for safety reason. See comments for more details.")]
void NextWorldUpdateAsync(Func<Task?> task)
Parameters
Exceptions

NextWorldUpdateAsync<T>(Func<Task<T?>>)

Never use this! you should never calls async callback in next world update, because async callback have chance to run in async context, which breaks the the synchronization safety this function gives.

[Obsolete("Please remove the async modifier on your callback for safety reason. See comments for more details.")]
Task<T> NextWorldUpdateAsync<T>(Func<Task<T?>> task)
Parameters
Returns
Type Parameters
  • T
Exceptions

NextWorldUpdateAsync<T>(Func<T>)

Add a task to be executed on the next world update asynchronously.

Task<T> NextWorldUpdateAsync<T>(Func<T> task)
Parameters
  • task Func<T> — The task to execute.
Returns
Type Parameters
  • T

Repeat(int, Action)

Add a repeated task to the scheduler. This will be executed once immediately, and then every periodTick ticks.

CancellationTokenSource Repeat(int periodTick, Action task)
Parameters
  • periodTick int — The period of the timer in ticks.
  • task Action — The task to execute.
Returns

RepeatBySeconds(float, Action)

Add a repeated task to the scheduler. This will be executed once immediately, and then every periodSeconds seconds.

The timing is based on game tick, which means it becomes inaccurate when intervals approachs 1 tick (approximately 15ms).

CancellationTokenSource RepeatBySeconds(float periodSeconds, Action task)
Parameters
  • periodSeconds float — The period of the timer in seconds.
  • task Action — The task to execute.
Returns

StopOnMapChange(CancellationTokenSource)

Stop a timer when the map changes.

void StopOnMapChange(CancellationTokenSource cts)
Parameters

On this page