async Task IFindUsagesService.FindReferencesAsync( Document document, int position, IFindUsagesContext context) { var definitionTrackingContext = new DefinitionTrackingContext(context); // Need ConfigureAwait(true) here so we get back to the UI thread before calling // GetThirdPartyDefinitions. We need to call that on the UI thread to match behavior // of how the language service always worked in the past. // // Any async calls before GetThirdPartyDefinitions must be ConfigureAwait(true). await FindLiteralOrSymbolReferencesAsync( document, position, definitionTrackingContext).ConfigureAwait(true); // After the FAR engine is done call into any third party extensions to see // if they want to add results. var thirdPartyDefinitions = GetThirdPartyDefinitions( document.Project.Solution, definitionTrackingContext.GetDefinitions(), context.CancellationToken); // From this point on we can do ConfigureAwait(false) as we're not calling back // into third parties anymore. foreach (var definition in thirdPartyDefinitions) { // Don't need ConfigureAwait(true) here await context.OnDefinitionFoundAsync(definition).ConfigureAwait(false); } }
async Task IFindUsagesService.FindReferencesAsync( IFindUsagesContext context, Document document, int position, CancellationToken cancellationToken) { var definitionTrackingContext = new DefinitionTrackingContext(context); await FindLiteralOrSymbolReferencesAsync( definitionTrackingContext, document, position, cancellationToken).ConfigureAwait(false); // After the FAR engine is done call into any third party extensions to see // if they want to add results. var thirdPartyDefinitions = await GetThirdPartyDefinitionsAsync( document.Project.Solution, definitionTrackingContext.GetDefinitions(), cancellationToken).ConfigureAwait(false); foreach (var definition in thirdPartyDefinitions) { await context.OnDefinitionFoundAsync(definition, cancellationToken).ConfigureAwait(false); } }