@@ -34,11 +34,9 @@ protected override Task OnStart()
34
34
return Task . FromResult ( true ) ;
35
35
}
36
36
37
- protected override Task OnStop ( )
37
+ protected override async Task OnStop ( )
38
38
{
39
- this . Shutdown ( ) ;
40
-
41
- return Task . FromResult ( true ) ;
39
+ await this . Shutdown ( ) ;
42
40
}
43
41
44
42
/// <summary>
@@ -49,37 +47,37 @@ protected override Task OnStop()
49
47
50
48
/// <summary>
51
49
/// 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.
53
52
/// </summary>
54
- protected virtual void Shutdown ( )
53
+ protected virtual Task Shutdown ( )
55
54
{
56
55
// No default implementation yet.
56
+ return Task . FromResult ( true ) ;
57
57
}
58
58
59
- private Task HandleShutdownRequest (
59
+ private async Task HandleShutdownRequest (
60
60
object shutdownParams ,
61
61
RequestContext < object > requestContext )
62
62
{
63
63
// Allow the implementor to shut down gracefully
64
- this . Shutdown ( ) ;
64
+ await this . Shutdown ( ) ;
65
65
66
- return requestContext . SendResult ( new object ( ) ) ;
66
+ await requestContext . SendResult ( new object ( ) ) ;
67
67
}
68
68
69
- private Task HandleExitNotification (
69
+ private async Task HandleExitNotification (
70
70
object exitParams ,
71
71
EventContext eventContext )
72
72
{
73
73
// Stop the server channel
74
- this . Stop ( ) ;
74
+ await this . Stop ( ) ;
75
75
76
76
// Notify any waiter that the server has exited
77
77
if ( this . serverExitedTask != null )
78
78
{
79
79
this . serverExitedTask . SetResult ( true ) ;
80
80
}
81
-
82
- return Task . FromResult ( true ) ;
83
81
}
84
82
}
85
83
}
0 commit comments