File tree Expand file tree Collapse file tree 5 files changed +19
-8
lines changed
Expand file tree Collapse file tree 5 files changed +19
-8
lines changed Original file line number Diff line number Diff line change @@ -26,7 +26,7 @@ static async Task MainAsync(string[] args)
2626 server . AddHandler ( new TextDocumentHandler ( server ) ) ;
2727
2828 await server . Initialize ( ) ;
29- await server . WasShutDown ;
29+ await server . WaitForExit ;
3030 }
3131 }
3232}
Original file line number Diff line number Diff line change 1- namespace OmniSharp . Extensions . LanguageServer . Server . Abstractions
1+ using System . Threading . Tasks ;
2+
3+ namespace OmniSharp . Extensions . LanguageServer . Server . Abstractions
24{
35 public interface IAwaitableTermination
46 {
5- System . Threading . Tasks . Task WasShutDown { get ; }
7+ Task WasShutDown { get ; }
8+ Task WaitForExit { get ; }
69 }
7- }
10+ }
Original file line number Diff line number Diff line change 11using System . Threading . Tasks ;
22using OmniSharp . Extensions . LanguageServer . Protocol ;
3+ using OmniSharp . Extensions . LanguageServer . Server . Abstractions ;
34
45namespace OmniSharp . Extensions . LanguageServer . Server . Handlers
56{
@@ -12,9 +13,15 @@ public ExitHandler(ShutdownHandler shutdownHandler)
1213 _shutdownHandler = shutdownHandler ;
1314 }
1415
16+ private readonly TaskCompletionSource < int > _exitedSource = new TaskCompletionSource < int > ( TaskContinuationOptions . LongRunning ) ;
17+ public Task WaitForExit => _exitedSource . Task ;
18+
19+
1520 public Task Handle ( )
1621 {
17- Exit ? . Invoke ( _shutdownHandler . ShutdownRequested ? 0 : 1 ) ;
22+ var result = _shutdownHandler . ShutdownRequested ? 0 : 1 ;
23+ Exit ? . Invoke ( result ) ;
24+ _exitedSource . SetResult ( result ) ;
1825 return Task . CompletedTask ;
1926 }
2027
Original file line number Diff line number Diff line change 55
66namespace OmniSharp . Extensions . LanguageServer . Server . Handlers
77{
8- public class ShutdownHandler : IShutdownHandler , IAwaitableTermination
8+ public class ShutdownHandler : IShutdownHandler
99 {
1010 public event ShutdownEventHandler Shutdown ;
1111
1212 public bool ShutdownRequested { get ; private set ; }
1313
1414 private readonly TaskCompletionSource < bool > _shutdownSource = new TaskCompletionSource < bool > ( TaskContinuationOptions . LongRunning ) ;
15- Task IAwaitableTermination . WasShutDown => _shutdownSource . Task ;
15+ public Task WasShutDown => _shutdownSource . Task ;
1616 public Task Handle ( object request , CancellationToken token )
1717 {
1818 ShutdownRequested = true ;
Original file line number Diff line number Diff line change @@ -329,7 +329,8 @@ public TaskCompletionSource<JToken> GetRequest(long id)
329329 return _responseRouter . GetRequest ( id ) ;
330330 }
331331
332- public Task WasShutDown => ( ( IAwaitableTermination ) _shutdownHandler ) . WasShutDown ;
332+ public Task WasShutDown => _shutdownHandler . WasShutDown ;
333+ public Task WaitForExit => _exitHandler . WaitForExit ;
333334
334335 public void Dispose ( )
335336 {
You can’t perform that action at this time.
0 commit comments