Class Timers
Factory methods for instantiating timers.
Namespace: Microsoft.Psi
Assembly: Microsoft.Psi.dll
Syntax
public static class Timers : object
Methods
View SourceTimer(Pipeline, TimeSpan, String)
Generates a stream of
Declaration
public static IProducer<TimeSpan> Timer(Pipeline pipeline, TimeSpan interval, string name = "Timer")
Parameters
Type | Name | Description |
---|---|---|
Pipeline | pipeline | The pipeline to add the component to. |
TimeSpan | interval | The interval at which to generate messages. |
String | name | An optional name for the component. |
Returns
Type | Description |
---|---|
IProducer<TimeSpan> | A stream of messages representing time elapsed since the start of the pipeline. |
Timer<T>(Pipeline, TimeSpan, Func<DateTime, TimeSpan, T>, String)
Generates a stream by invoking a user-provided function at a regular time interval. Unlike the generators available in the Generators class, this operator relies on an OS timer. This guarantees that messages are emitted at regular wall-clock intervals regardless of pipeline load. When the pipeline is in replay mode, the originating times of the messages are derived from the virtual pipeline time, but if the pipeline slows down, the interval between messages might not appear constant.
Declaration
public static IProducer<T> Timer<T>(Pipeline pipeline, TimeSpan interval, Func<DateTime, TimeSpan, T> generatorFn, string name = "Timer")
Parameters
Type | Name | Description |
---|---|---|
Pipeline | pipeline | The pipeline to add the component to. |
TimeSpan | interval | The interval at which to generate messages. |
Func<DateTime, TimeSpan, T> | generatorFn | The function generating the messages. |
String | name | An optional name for the component. |
Returns
Type | Description |
---|---|
IProducer<T> | A stream of messages of type T. |
Type Parameters
Name | Description |
---|---|
T | The type of data in the sequence. |