private async Task ReloadAsync(bool forceFindCodeReferences)
        {
            var cancellationTokenSource = new CancellationTokenSource();
            var cancellationToken       = cancellationTokenSource.Token;

            Interlocked.Exchange(ref _loadingCancellationTokenSource, cancellationTokenSource)?.Cancel();

            try
            {
                IsLoading = true;

                using (_performanceTracer.Start("ResourceManager.Load"))
                {
                    var sourceFiles = await _sourceFilesProvider.GetSourceFilesAsync(cancellationToken).ConfigureAwait(true);

                    if (cancellationToken.IsCancellationRequested)
                    {
                        return;
                    }

                    _codeReferenceTracker.StopFind();

                    if (await ResourceManager.ReloadAsync(sourceFiles, cancellationToken).ConfigureAwait(true) || forceFindCodeReferences)
                    {
                        BeginFindCodeReferences();
                    }
                }
            }
            catch (OperationCanceledException)
            {
            }
            catch (Exception ex)
            {
                _tracer.TraceError(ex.ToString());
            }
            finally
            {
                if (Interlocked.CompareExchange(ref _loadingCancellationTokenSource, null, cancellationTokenSource) == cancellationTokenSource)
                {
                    IsLoading = false;
                }

                cancellationTokenSource.Dispose();
            }
        }
        private void Reload(bool forceFindCodeReferences)
        {
            try
            {
                using (_performanceTracer.Start("ResourceManager.Load"))
                {
                    var sourceFiles = _sourceFilesProvider.SourceFiles;

                    _codeReferenceTracker.StopFind();

                    if (ResourceManager.Reload(sourceFiles) || forceFindCodeReferences)
                    {
                        BeginFindCodeReferences();
                    }
                }
            }
            catch (Exception ex)
            {
                _tracer.TraceError(ex.ToString());
            }
        }
Example #3
0
        public void Reload(bool forceFindCodeReferences)
        {
            try
            {
                using (_performanceTracer.Start("ResourceManager.Load"))
                {
                    var sourceFiles = _sourceFilesProvider.SourceFiles;

                    _codeReferenceTracker.StopFind();

                    if (_resourceManager.Reload(sourceFiles, _configuration.DuplicateKeyHandling) || forceFindCodeReferences)
                    {
                        _restartFindCodeReferencesThrottle.Tick();
                    }

                    _configuration.Reload();
                }
            }
            catch (Exception ex)
            {
                _tracer.TraceError(ex.ToString());
            }
        }