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

A task that reoccurs until TaskResult is remove. Keeps track of number of invocations Evaluates as many times within time restriction as allowable More...

Inheritance diagram for pluginbase.Objects.Tasks.IterativeTask:
pluginbase.Objects.Tasks.ITask

Public Member Functions

 IterativeTask (Func< int, TaskResult > method)
 
 IterativeTask (IIterableSystem system)
 
TaskResult InvokeTask (long maxMilliseconds)
 
override string ToString ()
 

Properties

TimeSpan Frequency [get]
 
- Properties inherited from pluginbase.Objects.Tasks.ITask
TimeSpan Frequency [get]
 

Detailed Description

A task that reoccurs until TaskResult is remove. Keeps track of number of invocations Evaluates as many times within time restriction as allowable

Constructor & Destructor Documentation

◆ IterativeTask() [1/2]

pluginbase.Objects.Tasks.IterativeTask.IterativeTask ( Func< int, TaskResult method)
17  {
18  _method = method;
19  }

◆ IterativeTask() [2/2]

pluginbase.Objects.Tasks.IterativeTask.IterativeTask ( IIterableSystem  system)
22  {
23  _method = system.Iterate;
24  }

Member Function Documentation

◆ InvokeTask()

TaskResult pluginbase.Objects.Tasks.IterativeTask.InvokeTask ( long  maxMilliseconds)

Implements pluginbase.Objects.Tasks.ITask.

28  {
29  var sw = new Stopwatch();
30  sw.Start();
31  while (sw.ElapsedMilliseconds < maxMilliseconds)
32  {
33  if (_method(_runCount) == TaskResult.Remove)
34  {
35  return TaskResult.Remove;
36  }
37  _runCount++;
38  }
39  sw.Stop();
40  return TaskResult.Continue;
41  }
TaskResult
The result of a scheduled task
Definition: TaskResult.cs:8

◆ ToString()

override string pluginbase.Objects.Tasks.IterativeTask.ToString ( )
50  {
51  return string.Format("[IterativeTask: Frequency={0}, {1}]", Frequency, _method.Method.Name);
52  }
TimeSpan Frequency
Definition: IterativeTask.cs:43

Property Documentation

◆ Frequency

TimeSpan pluginbase.Objects.Tasks.IterativeTask.Frequency
get

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