Skip to content

Latest commit

 

History

History
18 lines (15 loc) · 1.1 KB

File metadata and controls

18 lines (15 loc) · 1.1 KB

SimpleLoops

Simple library for running async loops

How to use it

SimpleLoopsBackgroundService detects all ISimpleLoop service registrations (such as services.AddSingleton<ISimpleLoop, SimpleLoop<<T>()) and run them.
At minimum, the following services needs to be registered:

services.AddHostedService<SimpleLoopsBackgroundService>();                       /* background service which runs the loops */
services.AddSingleton<ISimpleLoop, SimpleLoop<ISimpleLoopIterationExecutor>>();  /* the loop */
services.AddSingleton<ISimpleLoopIterationExecutor, LoopItemExecutor>();         /* loop iteration executor which contains the logic executed at every iteration */
services.AddSingleton<SimpleLoopConfiguration<ISimpleLoopIterationExecutor>>();  /* optional, loop configuration otherwise the default configuration will be used */

/* dependencies */
services.AddSingleton<ITask, TaskDelayWrapper>();
services.AddSingleton<IDateTime, DateTimeWrapper>();

Code sample