11using System ;
22using Simplify . DI ;
3+ using Simplify . Scheduler ;
4+ using Simplify . Scheduler . Jobs ;
5+ using Simplify . Scheduler . SimpleApp ;
36using Simplify . Scheduler . SimpleApp . Setup ;
47
5- namespace Simplify . Scheduler . SimpleApp ;
8+ // IOC container setup
69
7- internal class Program
8- {
9- private static void Main ( string [ ] args )
10- {
11- // IOC container setup
10+ DIContainer . Current
11+ . RegisterAll ( )
12+ . Verify ( ) ;
1213
13- IocRegistrations . Register ( )
14- . Verify ( ) ;
14+ // Using scheduler
1515
16- // Using scheduler
16+ using var scheduler = new MultitaskScheduler ( ) ;
1717
18- using ( var scheduler = new MultitaskScheduler ( ) )
19- {
20- scheduler . OnJobStart += HandlerOnJobStart ;
21- scheduler . OnJobFinish += HandlerOnJobFinish ;
18+ scheduler . OnJobStart += ( ISchedulerJobRepresentation representation ) => Console . WriteLine ( "Job started: " + representation . JobClassType . Name ) ;
19+ scheduler . OnJobFinish += ( ISchedulerJobRepresentation representation ) => Console . WriteLine ( "Job finished: " + representation . JobClassType . Name ) ;
2220
23- scheduler . AddJob < PeriodicalProcessor > ( IocRegistrations . Configuration ) ;
21+ scheduler . AddJob < PeriodicalProcessor > ( IocRegistrations . Configuration ) ;
2422
25- if ( scheduler . Start ( args ) )
26- return ;
27- }
23+ if ( await scheduler . StartAsync ( args ) )
24+ return ;
2825
29- // Testing without scheduler
30- using ( var scope = DIContainer . Current . BeginLifetimeScope ( ) )
31- scope . Resolver . Resolve < PeriodicalProcessor > ( ) . Run ( ) ;
32- }
33-
34- private static void HandlerOnJobStart ( Jobs . ISchedulerJobRepresentation representation )
35- {
36- Console . WriteLine ( "Job started: " + representation . JobClassType . Name ) ;
37- }
38-
39- private static void HandlerOnJobFinish ( Jobs . ISchedulerJobRepresentation representation )
40- {
41- Console . WriteLine ( "Job finished: " + representation . JobClassType . Name ) ;
42- }
43- }
26+ // Testing without scheduler
27+ using ( var scope = DIContainer . Current . BeginLifetimeScope ( ) )
28+ scope . Resolver . Resolve < PeriodicalProcessor > ( ) . Run ( ) ;
0 commit comments