File tree Expand file tree Collapse file tree 1 file changed +11
-4
lines changed Expand file tree Collapse file tree 1 file changed +11
-4
lines changed Original file line number Diff line number Diff line change @@ -13,12 +13,19 @@ public class ShutdownHandler : IShutdownHandler
13
13
14
14
private readonly TaskCompletionSource < bool > _shutdownSource = new TaskCompletionSource < bool > ( TaskContinuationOptions . LongRunning ) ;
15
15
public Task WasShutDown => _shutdownSource . Task ;
16
- public Task Handle ( object request , CancellationToken token )
16
+ public async Task Handle ( object request , CancellationToken token )
17
17
{
18
+ await Task . Yield ( ) ; // Ensure shutdown handler runs asynchronously.
19
+
18
20
ShutdownRequested = true ;
19
- Shutdown ? . Invoke ( ShutdownRequested ) ;
20
- _shutdownSource . SetResult ( true ) ; // after all event sinks were notified
21
- return Task . CompletedTask ;
21
+ try
22
+ {
23
+ Shutdown ? . Invoke ( ShutdownRequested ) ;
24
+ }
25
+ finally
26
+ {
27
+ _shutdownSource . SetResult ( true ) ; // after all event sinks were notified
28
+ }
22
29
}
23
30
}
24
31
}
You can’t perform that action at this time.
0 commit comments