Skip to content

STREAMS - Refresh Timer

There are scenarios where you want to have data requests be called every so often. The RefreshTimer middleware is designed to help you with this.

[RefreshTimer(3000)] // every 3 seconds
public class MyStreamRequestHandler : IStreamRequestHandler<MyRequest, string>
{
public async IAsyncEnumerable<string> Handle(MyRequest request, [EnumeratorCancellation] CancellationToken cancellationToken)
{
yield return DateTimeOffset.Now.ToString("h:mm:ss tt");
}
}

Use this in focused areas without something like cache and offline on top of the request.