提交 9d2378f2 编写于 作者: C CyrusNajmabadi

Kick off work to the BG to ensure the UI thread doesn't need to block.

上级 fccae4ec
......@@ -531,14 +531,13 @@ protected override bool TryExec(Guid commandGroup, uint commandId)
var cancellationToken = context.CancellationToken;
// Fire and forget the work to go get references.
var compilation = await project.GetCompilationAsync(cancellationToken).ConfigureAwait(false);
var symbol = symbolListItem.ResolveSymbol(compilation);
if (symbol != null)
// Kick off the work to do the actual finding on a BG thread. That way we don'
// t block the calling (UI) thread too long if we happen to do our work on this
// thread.
await Task.Run(async () =>
{
await AbstractFindUsagesService.FindSymbolReferencesAsync(
context, symbol, project, cancellationToken).ConfigureAwait(false);
}
await FindReferencesAsync(symbolListItem, project, context, cancellationToken).ConfigureAwait(false);
}, cancellationToken).ConfigureAwait(false);
// Note: we don't need to put this in a finally. The only time we might not hit
// this is if cancellation or another error gets thrown. In the former case,
......@@ -554,5 +553,16 @@ protected override bool TryExec(Guid commandGroup, uint commandId)
{
}
}
private static async Task FindReferencesAsync(SymbolListItem symbolListItem, Project project, CodeAnalysis.FindUsages.FindUsagesContext context, CancellationToken cancellationToken)
{
var compilation = await project.GetCompilationAsync(cancellationToken).ConfigureAwait(false);
var symbol = symbolListItem.ResolveSymbol(compilation);
if (symbol != null)
{
await AbstractFindUsagesService.FindSymbolReferencesAsync(
context, symbol, project, cancellationToken).ConfigureAwait(false);
}
}
}
}
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册