File tree 5 files changed +19
-8
lines changed
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)
26
26
server . AddHandler ( new TextDocumentHandler ( server ) ) ;
27
27
28
28
await server . Initialize ( ) ;
29
- await server . WasShutDown ;
29
+ await server . WaitForExit ;
30
30
}
31
31
}
32
32
}
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
2
4
{
3
5
public interface IAwaitableTermination
4
6
{
5
- System . Threading . Tasks . Task WasShutDown { get ; }
7
+ Task WasShutDown { get ; }
8
+ Task WaitForExit { get ; }
6
9
}
7
- }
10
+ }
Original file line number Diff line number Diff line change 1
1
using System . Threading . Tasks ;
2
2
using OmniSharp . Extensions . LanguageServer . Protocol ;
3
+ using OmniSharp . Extensions . LanguageServer . Server . Abstractions ;
3
4
4
5
namespace OmniSharp . Extensions . LanguageServer . Server . Handlers
5
6
{
@@ -12,9 +13,15 @@ public ExitHandler(ShutdownHandler shutdownHandler)
12
13
_shutdownHandler = shutdownHandler ;
13
14
}
14
15
16
+ private readonly TaskCompletionSource < int > _exitedSource = new TaskCompletionSource < int > ( TaskContinuationOptions . LongRunning ) ;
17
+ public Task WaitForExit => _exitedSource . Task ;
18
+
19
+
15
20
public Task Handle ( )
16
21
{
17
- Exit ? . Invoke ( _shutdownHandler . ShutdownRequested ? 0 : 1 ) ;
22
+ var result = _shutdownHandler . ShutdownRequested ? 0 : 1 ;
23
+ Exit ? . Invoke ( result ) ;
24
+ _exitedSource . SetResult ( result ) ;
18
25
return Task . CompletedTask ;
19
26
}
20
27
Original file line number Diff line number Diff line change 5
5
6
6
namespace OmniSharp . Extensions . LanguageServer . Server . Handlers
7
7
{
8
- public class ShutdownHandler : IShutdownHandler , IAwaitableTermination
8
+ public class ShutdownHandler : IShutdownHandler
9
9
{
10
10
public event ShutdownEventHandler Shutdown ;
11
11
12
12
public bool ShutdownRequested { get ; private set ; }
13
13
14
14
private readonly TaskCompletionSource < bool > _shutdownSource = new TaskCompletionSource < bool > ( TaskContinuationOptions . LongRunning ) ;
15
- Task IAwaitableTermination . WasShutDown => _shutdownSource . Task ;
15
+ public Task WasShutDown => _shutdownSource . Task ;
16
16
public Task Handle ( object request , CancellationToken token )
17
17
{
18
18
ShutdownRequested = true ;
Original file line number Diff line number Diff line change @@ -329,7 +329,8 @@ public TaskCompletionSource<JToken> GetRequest(long id)
329
329
return _responseRouter . GetRequest ( id ) ;
330
330
}
331
331
332
- public Task WasShutDown => ( ( IAwaitableTermination ) _shutdownHandler ) . WasShutDown ;
332
+ public Task WasShutDown => _shutdownHandler . WasShutDown ;
333
+ public Task WaitForExit => _exitHandler . WaitForExit ;
333
334
334
335
public void Dispose ( )
335
336
{
You can’t perform that action at this time.
0 commit comments