File tree Expand file tree Collapse file tree 2 files changed +9
-28
lines changed
src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/Diagnostics Expand file tree Collapse file tree 2 files changed +9
-28
lines changed Original file line number Diff line number Diff line change @@ -20,23 +20,15 @@ public bool IsWaitingToClearClosedDocuments
20
20
{
21
21
get
22
22
{
23
- lock ( instance . _documentClosedGate )
24
- {
25
- return instance . _waitingToClearClosedDocuments ;
26
- }
23
+ return ! instance . _clearClosedDocumentsTask . IsCompleted ;
27
24
}
28
25
}
29
26
30
- public async Task WaitForClearClosedDocumentsAsync ( )
27
+ public Task WaitForClearClosedDocumentsAsync ( )
31
28
{
32
- Task task ;
33
-
34
- lock ( instance . _documentClosedGate )
35
- {
36
- task = instance . _clearClosedDocumentsTask ;
37
- }
38
-
39
- await task . ConfigureAwait ( false ) ;
29
+ #pragma warning disable VSTHRD003 // Avoid awaiting foreign Tasks
30
+ return instance . _clearClosedDocumentsTask ;
31
+ #pragma warning restore VSTHRD003 // Avoid awaiting foreign Tasks
40
32
}
41
33
42
34
public Task WaitForDiagnosticsToPublishAsync ( )
Original file line number Diff line number Diff line change @@ -43,9 +43,7 @@ private readonly record struct PublishedDiagnostics(IReadOnlyList<RazorDiagnosti
43
43
private readonly AsyncBatchingWorkQueue < IDocumentSnapshot > _workQueue ;
44
44
private readonly Dictionary < string , PublishedDiagnostics > _publishedDiagnostics ;
45
45
46
- private readonly object _documentClosedGate = new ( ) ;
47
46
private Task _clearClosedDocumentsTask = Task . CompletedTask ;
48
- private bool _waitingToClearClosedDocuments ;
49
47
50
48
public RazorDiagnosticsPublisher (
51
49
IProjectSnapshotManager projectManager ,
@@ -204,27 +202,18 @@ .. csharpDiagnostics ?? []
204
202
205
203
private void StartDelayToClearDocuments ( )
206
204
{
207
- lock ( _documentClosedGate )
205
+ if ( ! _clearClosedDocumentsTask . IsCompleted )
208
206
{
209
- if ( _waitingToClearClosedDocuments )
210
- {
211
- return ;
212
- }
213
-
214
- _clearClosedDocumentsTask = ClearClosedDocumentsAfterDelayAsync ( ) ;
215
- _waitingToClearClosedDocuments = true ;
207
+ return ;
216
208
}
217
209
210
+ _clearClosedDocumentsTask = ClearClosedDocumentsAfterDelayAsync ( ) ;
211
+
218
212
async Task ClearClosedDocumentsAfterDelayAsync ( )
219
213
{
220
214
await Task . Delay ( s_clearClosedDocumentsDelay , _disposeTokenSource . Token ) . ConfigureAwait ( false ) ;
221
215
222
216
ClearClosedDocuments ( ) ;
223
-
224
- lock ( _documentClosedGate )
225
- {
226
- _waitingToClearClosedDocuments = false ;
227
- }
228
217
}
229
218
}
230
219
You can’t perform that action at this time.
0 commit comments