Empeld
Empeld plugin documentation.
pluginbase.Objects.Tasks.ChainedTaskExtensions Class Reference

Static Public Member Functions

static ChainedTask Then (this ITask task, ITask nextTask)
 Chain a task to run after a given task More...
 
static ChainedTask Then (this ITask task, Action method)
 Execute an action More...
 
static ChainedTask Then (this ITask task, Action method, TimeSpan delay)
 Execute an action after a delay More...
 
static ChainedTask Then (this ITask task, Action method, int repeat, TimeSpan delay)
 Execute an action n times, with a delay More...
 
static ChainedTask Then (this ITask task, Func< TaskResult > method, TimeSpan frequency)
 Execute an action with a frequency until done More...
 
static ChainedTask Then (this ITask task, Func< IEnumerable< ITaskYieldAction >> yieldingTask)
 Execute a chained task More...
 
static ChainedTask Wait (this ITask task, TimeSpan timespan)
 Wait a timespan More...
 
static ChainedTask Wait (this ITask task, double seconds)
 Wait a timespan More...
 
static ChainedTask Wait (this ITask task, Func< bool > until)
 Wait until a delegate return true More...
 
static ChainedTask Wait (this ITask task, TimeSpan timespan, Action< double > tick, TimeSpan tickSpeed)
 Wait for a duration of time, and execute a tick after every increment More...
 
static ChainedTask Wait (this ITask task, TimeSpan timespan, Action< double > tick)
 Wait for a duration of time, and execute a tick after every 0.25 second increment More...
 
static ChainedTask Finally (this ITask task, Action< Exception > fin)
 Promise the specified task will always run after the task completes or fails More...
 
static ChainedTask Finally (this ITask task)
 Promises the task will finish running and now explode More...
 

Member Function Documentation

◆ Finally() [1/2]

static ChainedTask pluginbase.Objects.Tasks.ChainedTaskExtensions.Finally ( this ITask  task,
Action< Exception >  fin 
)
static

Promise the specified task will always run after the task completes or fails

Parameters
taskTask.
finPromise.
139  {
140  return ChainedTask.Chain(task).Finally(fin);
141  }

◆ Finally() [2/2]

static ChainedTask pluginbase.Objects.Tasks.ChainedTaskExtensions.Finally ( this ITask  task)
static

Promises the task will finish running and now explode

Parameters
taskTask.
148  {
149  return ChainedTask.Chain(task).Finally(x => {});
150  }

◆ Then() [1/6]

static ChainedTask pluginbase.Objects.Tasks.ChainedTaskExtensions.Then ( this ITask  task,
ITask  nextTask 
)
static

Chain a task to run after a given task

Parameters
taskTask.
nextTaskNext task.
14  {
15  return ChainedTask.Chain(task, nextTask);
16  }

◆ Then() [2/6]

static ChainedTask pluginbase.Objects.Tasks.ChainedTaskExtensions.Then ( this ITask  task,
Action  method 
)
static

Execute an action

Parameters
taskTask.
methodMethod.
24  {
25  return ChainedTask.Chain(task, new SingleTask(method, TimeSpan.Zero));
26  }

◆ Then() [3/6]

static ChainedTask pluginbase.Objects.Tasks.ChainedTaskExtensions.Then ( this ITask  task,
Action  method,
TimeSpan  delay 
)
static

Execute an action after a delay

Parameters
taskTask.
methodMethod.
delayDelay.
35  {
36  return ChainedTask.Chain(task, new SingleTask(method, delay));
37  }

◆ Then() [4/6]

static ChainedTask pluginbase.Objects.Tasks.ChainedTaskExtensions.Then ( this ITask  task,
Action  method,
int  repeat,
TimeSpan  delay 
)
static

Execute an action n times, with a delay

Parameters
taskTask.
methodMethod.
repeatRepeat.
delayDelay.
47  {
48  return ChainedTask.Chain(task, new RepeatingTask(method, repeat, delay));
49  }

◆ Then() [5/6]

static ChainedTask pluginbase.Objects.Tasks.ChainedTaskExtensions.Then ( this ITask  task,
Func< TaskResult method,
TimeSpan  frequency 
)
static

Execute an action with a frequency until done

Parameters
taskTask.
methodMethod.
frequencyFrequency.
58  {
59  return ChainedTask.Chain(task, new RecurringTask(method, frequency));
60  }

◆ Then() [6/6]

static ChainedTask pluginbase.Objects.Tasks.ChainedTaskExtensions.Then ( this ITask  task,
Func< IEnumerable< ITaskYieldAction >>  yieldingTask 
)
static

Execute a chained task

Parameters
taskTask.
yieldingTaskYielding task.
68  {
69  return ChainedTask.Chain(task, new YieldingTask(yieldingTask));
70  }

◆ Wait() [1/5]

static ChainedTask pluginbase.Objects.Tasks.ChainedTaskExtensions.Wait ( this ITask  task,
TimeSpan  timespan 
)
static

Wait a timespan

Parameters
taskTask.
timespanTimespan.
78  {
79  return ChainedTask.Chain(task, new SingleTask(() => {}, timespan));
80  }

◆ Wait() [2/5]

static ChainedTask pluginbase.Objects.Tasks.ChainedTaskExtensions.Wait ( this ITask  task,
double  seconds 
)
static

Wait a timespan

Parameters
taskTask.
secondsSeconds.
88  {
89  return ChainedTask.Chain(task, new SingleTask(() => {}, TimeSpan.FromSeconds(seconds)));
90  }

◆ Wait() [3/5]

static ChainedTask pluginbase.Objects.Tasks.ChainedTaskExtensions.Wait ( this ITask  task,
Func< bool >  until 
)
static

Wait until a delegate return true

Parameters
taskTask.
untilUntil.
98  {
99  return ChainedTask.Chain(task, new RecurringTask( () => until() ? TaskResult.Remove : TaskResult.Continue, TimeSpan.FromSeconds(0.1) ));
100  }
TaskResult
The result of a scheduled task
Definition: TaskResult.cs:8

◆ Wait() [4/5]

static ChainedTask pluginbase.Objects.Tasks.ChainedTaskExtensions.Wait ( this ITask  task,
TimeSpan  timespan,
Action< double >  tick,
TimeSpan  tickSpeed 
)
static

Wait for a duration of time, and execute a tick after every increment

Parameters
taskTask.
timespanTimespan.
tickTick.
tickSpeedTick speed.
110  {
111  int repeatCount = (int)Math.Ceiling(timespan.TotalSeconds / tickSpeed.TotalSeconds);
112  int i = 0;
113  return Then(task,
114  () => {
115  i++;
116  tick(tickSpeed.TotalSeconds * i);
117  },
118  repeatCount,
119  tickSpeed);
120  }
static ChainedTask Then(this ITask task, ITask nextTask)
Chain a task to run after a given task
Definition: ChainedTaskExtensions.cs:13

◆ Wait() [5/5]

static ChainedTask pluginbase.Objects.Tasks.ChainedTaskExtensions.Wait ( this ITask  task,
TimeSpan  timespan,
Action< double >  tick 
)
static

Wait for a duration of time, and execute a tick after every 0.25 second increment

Parameters
taskTask.
timespanTimespan.
tickTick.
129  {
130  return Wait(task, timespan, tick, TimeSpan.FromSeconds(0.25));
131  }
static ChainedTask Wait(this ITask task, TimeSpan timespan)
Wait a timespan
Definition: ChainedTaskExtensions.cs:77

The documentation for this class was generated from the following file: