@@ -34,11 +34,9 @@ protected override Task OnStart()
3434 return Task . FromResult ( true ) ;
3535 }
3636
37- protected override Task OnStop ( )
37+ protected override async Task OnStop ( )
3838 {
39- this . Shutdown ( ) ;
40-
41- return Task . FromResult ( true ) ;
39+ await this . Shutdown ( ) ;
4240 }
4341
4442 /// <summary>
@@ -49,37 +47,37 @@ protected override Task OnStop()
4947
5048 /// <summary>
5149 /// Can be overridden by the subclass to provide shutdown
52- /// logic before the server exits.
50+ /// logic before the server exits. Subclasses do not need
51+ /// to invoke or return the value of the base implementation.
5352 /// </summary>
54- protected virtual void Shutdown ( )
53+ protected virtual Task Shutdown ( )
5554 {
5655 // No default implementation yet.
56+ return Task . FromResult ( true ) ;
5757 }
5858
59- private Task HandleShutdownRequest (
59+ private async Task HandleShutdownRequest (
6060 object shutdownParams ,
6161 RequestContext < object > requestContext )
6262 {
6363 // Allow the implementor to shut down gracefully
64- this . Shutdown ( ) ;
64+ await this . Shutdown ( ) ;
6565
66- return requestContext . SendResult ( new object ( ) ) ;
66+ await requestContext . SendResult ( new object ( ) ) ;
6767 }
6868
69- private Task HandleExitNotification (
69+ private async Task HandleExitNotification (
7070 object exitParams ,
7171 EventContext eventContext )
7272 {
7373 // Stop the server channel
74- this . Stop ( ) ;
74+ await this . Stop ( ) ;
7575
7676 // Notify any waiter that the server has exited
7777 if ( this . serverExitedTask != null )
7878 {
7979 this . serverExitedTask . SetResult ( true ) ;
8080 }
81-
82- return Task . FromResult ( true ) ;
8381 }
8482 }
8583}
0 commit comments