Skip to content

Commit c00aa0e

Browse files
Async token
1 parent 92cc8ef commit c00aa0e

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

src/EditorFeatures/Core.Wpf/Copilot/CopilotWpfTextCreationListener.cs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ internal sealed class CopilotWpfTextViewCreationListener : IWpfTextViewCreationL
3131
{
3232
private readonly IThreadingContext _threadingContext;
3333
private readonly Lazy<SuggestionServiceBase> _suggestionServiceBase;
34+
private readonly IAsynchronousOperationListener _listener;
3435

3536
private readonly AsyncBatchingWorkQueue<SuggestionAcceptedEventArgs> _workQueue;
3637

@@ -45,10 +46,11 @@ public CopilotWpfTextViewCreationListener(
4546
{
4647
_threadingContext = threadingContext;
4748
_suggestionServiceBase = suggestionServiceBase;
49+
_listener = listenerProvider.GetListener(FeatureAttribute.CopilotChangeAnalysis);
4850
_workQueue = new AsyncBatchingWorkQueue<SuggestionAcceptedEventArgs>(
4951
DelayTimeSpan.Idle,
5052
ProcessEventsAsync,
51-
listenerProvider.GetListener(FeatureAttribute.CopilotChangeAnalysis),
53+
_listener,
5254
_threadingContext.DisposalToken);
5355
}
5456

@@ -58,11 +60,12 @@ public void TextViewCreated(IWpfTextView textView)
5860
// from it.
5961
if (Interlocked.CompareExchange(ref _started, 1, 0) == 0)
6062
{
61-
_ = Task.Run(() =>
63+
var token = _listener.BeginAsyncOperation(nameof(TextViewCreated));
64+
Task.Run(() =>
6265
{
6366
var suggestionService = _suggestionServiceBase.Value;
6467
suggestionService.SuggestionAccepted += OnSuggestionAccepted;
65-
});
68+
}).CompletesAsyncOperation(token);
6669
}
6770
}
6871

src/Workspaces/Core/Portable/CodeActions/CodeAction.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
using System.ComponentModel;
99
using System.Diagnostics;
1010
using System.Diagnostics.CodeAnalysis;
11-
using System.Linq;
1211
using System.Threading;
1312
using System.Threading.Tasks;
1413
using Microsoft.CodeAnalysis.CodeCleanup;

0 commit comments

Comments
 (0)