Skip to content

Commit 3d1e56d

Browse files
shutdown is a request, not a notification
1 parent 201d765 commit 3d1e56d

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

src/Protocol/General/IShutdownHandler.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,5 @@ public static partial class GeneralNames
1111
}
1212

1313
[Serial, Method(Shutdown)]
14-
public interface IShutdownHandler : INotificationHandler { }
14+
public interface IShutdownHandler : IRequestHandler<object> { }
1515
}
+9-9
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
using System.Threading;
12
using System.Threading.Tasks;
23
using OmniSharp.Extensions.LanguageServer.Protocol;
34
using OmniSharp.Extensions.LanguageServer.Server.Abstractions;
@@ -6,19 +7,18 @@ namespace OmniSharp.Extensions.LanguageServer.Server.Handlers
67
{
78
public class ShutdownHandler : IShutdownHandler, IAwaitableTermination
89
{
9-
public Task Handle()
10+
public event ShutdownEventHandler Shutdown;
11+
12+
public bool ShutdownRequested { get; private set; }
13+
14+
private readonly TaskCompletionSource<bool> _shutdownSource = new TaskCompletionSource<bool>(TaskContinuationOptions.LongRunning);
15+
Task IAwaitableTermination.WasShutDown => _shutdownSource.Task;
16+
public Task Handle(object request, CancellationToken token)
1017
{
1118
ShutdownRequested = true;
1219
Shutdown?.Invoke(ShutdownRequested);
13-
shutdownSource.SetResult(true); // after all event sinks were notified
20+
_shutdownSource.SetResult(true); // after all event sinks were notified
1421
return Task.CompletedTask;
1522
}
16-
17-
public event ShutdownEventHandler Shutdown;
18-
19-
public bool ShutdownRequested { get; private set; }
20-
21-
private readonly TaskCompletionSource<bool> shutdownSource = new TaskCompletionSource<bool>(TaskContinuationOptions.LongRunning);
22-
Task IAwaitableTermination.WasShutDown => shutdownSource.Task;
2323
}
2424
}

0 commit comments

Comments
 (0)