@@ -14,7 +14,7 @@ public class LifeCycleEventPublisher : ILifeCycleEventPublisher, IDisposable
14
14
private readonly ILifeCycleEventHub _eventHub ;
15
15
private readonly ILogger _logger ;
16
16
private readonly BlockingCollection < LifeCycleEvent > _outbox ;
17
- protected Task DispatchTask ;
17
+ private Task _dispatchTask ;
18
18
19
19
public LifeCycleEventPublisher ( ILifeCycleEventHub eventHub , ILoggerFactory loggerFactory )
20
20
{
@@ -33,21 +33,20 @@ public void PublishNotification(LifeCycleEvent evt)
33
33
34
34
public void Start ( )
35
35
{
36
- if ( DispatchTask != null )
36
+ if ( _dispatchTask != null )
37
37
{
38
38
throw new InvalidOperationException ( ) ;
39
39
}
40
40
41
- DispatchTask = new Task ( Execute ) ;
42
- DispatchTask . Start ( ) ;
41
+ _dispatchTask = new Task ( Execute ) ;
42
+ _dispatchTask . Start ( ) ;
43
43
}
44
44
45
45
public void Stop ( )
46
46
{
47
47
_outbox . CompleteAdding ( ) ;
48
-
49
- DispatchTask . Wait ( ) ;
50
- DispatchTask = null ;
48
+ _dispatchTask . Wait ( ) ;
49
+ _dispatchTask = null ;
51
50
}
52
51
53
52
public void Dispose ( )
@@ -57,16 +56,16 @@ public void Dispose()
57
56
58
57
private async void Execute ( )
59
58
{
60
- try
59
+ foreach ( var evt in _outbox . GetConsumingEnumerable ( ) )
61
60
{
62
- foreach ( var evt in _outbox . GetConsumingEnumerable ( ) )
61
+ try
63
62
{
64
63
await _eventHub . PublishNotification ( evt ) ;
65
64
}
66
- }
67
- catch ( Exception ex )
68
- {
69
- _logger . LogError ( default ( EventId ) , ex , ex . Message ) ;
65
+ catch ( Exception ex )
66
+ {
67
+ _logger . LogError ( default ( EventId ) , ex , ex . Message ) ;
68
+ }
70
69
}
71
70
}
72
71
}
0 commit comments