Exemplo n.º 1
0
        public IProgressMonitor CreateProgressMonitor(CancellationToken cancellationToken = default(CancellationToken))
        {
            ProgressCollector progress = new ProgressCollector(SD.MainThread.SynchronizingObject, cancellationToken);

            AddProgress(progress);
            return(progress.ProgressMonitor);
        }
Exemplo n.º 2
0
        public IProgressMonitor CreateProgressMonitor(CancellationToken cancellationToken = default(CancellationToken))
        {
            ProgressCollector progress = new ProgressCollector(WorkbenchSingleton.Workbench.SynchronizingObject, cancellationToken);

            AddProgress(progress);
            return(progress.ProgressMonitor);
        }
 private async Task AddOperationAsync(IOperation operation, ISymbol symbol, CancellationToken cancellationToken)
 {
     _ = await ProgressCollector.TryReportAsync(
         Solution,
         operation.Syntax.GetLocation(),
         symbol,
         cancellationToken : cancellationToken).ConfigureAwait(false);
 }
 private AsynchronousWaitDialog(string titleName, string defaultTaskName, bool allowCancel, Action <IProgressMonitor> asyncOperation)
 {
     this.titleName       = StringParser.Parse(titleName);
     this.defaultTaskName = StringParser.Parse(defaultTaskName ?? ConstStringResources.GlobalPleaseWait);
     if (allowCancel)
     {
         this.cancellation = new CancellationTokenSource();
     }
     this.asyncOperation     = asyncOperation;
     this.runningInOwnThread = (asyncOperation == null);
     this.collector          = new ProgressCollector(synchronizationHelper, allowCancel ? cancellation.Token : CancellationToken.None);
 }
Exemplo n.º 5
0
 public void AddProgress(ProgressCollector progress)
 {
     if (progress == null)
     {
         throw new ArgumentNullException("progress");
     }
     WorkbenchSingleton.AssertMainThread();
     if (currentProgress != null)
     {
         currentProgress.ProgressMonitorDisposed -= progress_ProgressMonitorDisposed;
         currentProgress.PropertyChanged         -= progress_PropertyChanged;
     }
     waitingProgresses.Push(currentProgress); // push even if currentProgress==null
     SetActiveProgress(progress);
 }
Exemplo n.º 6
0
        private static async Task <LSP.VSReferenceItem[]> RunFindAllReferencesAsync(Solution solution, LSP.Location caret)
        {
            var vsClientCapabilities = new LSP.VSClientCapabilities
            {
                SupportsVisualStudioExtensions = true
            };

            var progress = new ProgressCollector <LSP.VSReferenceItem>();

            var queue = CreateRequestQueue(solution);

            await GetLanguageServer(solution).ExecuteRequestAsync <LSP.ReferenceParams, LSP.VSReferenceItem[]>(queue, LSP.Methods.TextDocumentReferencesName,
                                                                                                               CreateReferenceParams(caret, progress), vsClientCapabilities, null, CancellationToken.None);

            return(progress.GetItems());
        }
Exemplo n.º 7
0
        void SetActiveProgress(ProgressCollector progress)
        {
            WorkbenchSingleton.AssertMainThread();
            currentProgress = progress;
            if (progress == null)
            {
                statusBar.HideProgress();
                return;
            }

            progress.ProgressMonitorDisposed += progress_ProgressMonitorDisposed;
            if (progress.ProgressMonitorIsDisposed)
            {
                progress_ProgressMonitorDisposed(progress, null);
                return;
            }
            progress.PropertyChanged += progress_PropertyChanged;
        }
Exemplo n.º 8
0
        void SetActiveProgress(ProgressCollector progress)
        {
            SD.MainThread.VerifyAccess();
            currentProgress = progress;
            if (progress == null)
            {
                statusBar.HideProgress();
                return;
            }

            progress.ProgressMonitorDisposed += progress_ProgressMonitorDisposed;
            if (progress.ProgressMonitorIsDisposed)
            {
                progress_ProgressMonitorDisposed(progress, null);
                return;
            }
            progress.PropertyChanged += progress_PropertyChanged;
        }
Exemplo n.º 9
0
    public async Task User_can_download_a_video_and_track_the_progress_of_the_operation()
    {
        // Arrange
        var progress = new ProgressCollector <double>();

        var youtube        = new YoutubeClient();
        var outputFilePath = _tempOutputFixture.GetTempFilePath();

        // Act
        await youtube.Videos.DownloadAsync("AI7ULzgf8RU", outputFilePath, progress);

        // Assert
        var progressValues = progress.GetValues();

        progressValues.Should().NotBeEmpty();

        foreach (var value in progress.GetValues())
        {
            _testOutput.WriteLine($"Progress: {value:P2}");
        }
    }
Exemplo n.º 10
0
        public async Task YoutubeConverter_DownloadVideoAsync_Test(
            [ValueSource(typeof(TestData), nameof(TestData.VideoIds))] string videoId,
            [ValueSource(typeof(TestData), nameof(TestData.OutputFormats))] string format)
        {
            // Arrange
            Directory.CreateDirectory(TempDirPath);
            var outputFilePath = Path.Combine(TempDirPath, Guid.NewGuid().ToString());
            var progress       = new ProgressCollector <double>();
            var converter      = new YoutubeConverter();

            // Act
            await converter.DownloadVideoAsync(videoId, outputFilePath, format, progress);

            var fileInfo = new FileInfo(outputFilePath);

            // Assert
            Assert.Multiple(() =>
            {
                Assert.That(fileInfo.Exists, Is.True, "File exists");
                Assert.That(fileInfo.Length, Is.GreaterThan(0), "File size");
                Assert.That(progress.GetAll(), Is.Not.Empty, "Progress");
            });
        }
            private async Task TrackArgumentsAsync(ImmutableArray <IArgumentOperation> argumentOperations, CancellationToken cancellationToken)
            {
                var collectorsAndArgumentMap = argumentOperations
                                               .Where(ShouldTrackArgument)
                                               // Clone the collector here to allow each argument to report multiple items.
                                               // See Clone() docs for more details
                                               .Select(argument => (collector: Clone(), argument))
                                               .ToImmutableArray();

                var tasks = collectorsAndArgumentMap
                            .Select(pair => Task.Run(() => pair.collector.VisitAsync(pair.argument, cancellationToken)));

                await Task.WhenAll(tasks).ConfigureAwait(false);

                var items = collectorsAndArgumentMap
                            .Select(pair => pair.collector.ProgressCollector)
                            .SelectMany(collector => collector.GetItems())
                            .Reverse(); // ProgressCollector uses a Stack, and we want to maintain the order by arguments, so reverse

                foreach (var item in items)
                {
                    ProgressCollector.Report(item);
                }
            }
Exemplo n.º 12
0
 public void AddProgress(ProgressCollector progress)
 {
 }
 public void AddProgress(ProgressCollector progress)
 {
     throw new NotImplementedException();
 }