コード例 #1
0
        private async Task StartWorkerAsync()
        {
            var cancellationToken = ThreadingContext.DisposalToken;

            _workQueueSource.SetResult(
                new AsyncBatchingWorkQueue <DocumentAndComments>(
                    TimeSpan.FromSeconds(1),
                    ProcessTodoCommentInfosAsync,
                    cancellationToken));

            var client = await RemoteHostClient.TryGetClientAsync(_workspace, cancellationToken).ConfigureAwait(false);

            if (client == null)
            {
                ComputeTodoCommentsInCurrentProcess(cancellationToken);
                return;
            }

            // Pass ourselves in as the callback target for the OOP service.  As it discovers
            // todo comments it will call back into us to notify VS about it.
            _lazyConnection = await client.CreateConnectionAsync <IRemoteTodoCommentsDiscoveryService>(callbackTarget : this, cancellationToken).ConfigureAwait(false);

            // Now that we've started, let the VS todo list know to start listening to us
            _eventListenerTracker.EnsureEventListener(_workspace, this);

            // Now kick off scanning in the OOP process.
            // If the call fails an error has already been reported and there is nothing more to do.
            _ = await _lazyConnection.TryInvokeAsync(
                (service, cancellationToken) => service.ComputeTodoCommentsAsync(cancellationToken),
                cancellationToken).ConfigureAwait(false);
        }
コード例 #2
0
        private async Task StartWorkerAsync()
        {
            var cancellationToken = ThreadingContext.DisposalToken;

            var client = await RemoteHostClient
                         .TryGetClientAsync(_workspace, cancellationToken)
                         .ConfigureAwait(false);

            if (client == null)
            {
                return;
            }

            // Pass ourselves in as the callback target for the OOP service.  As it discovers
            // designer attributes it will call back into us to notify VS about it.
            _lazyConnection = client.CreateConnection <IRemoteProjectTelemetryService>(
                callbackTarget: this
                );

            // Now kick off scanning in the OOP process.
            // If the call fails an error has already been reported and there is nothing more to do.
            _ = await _lazyConnection
                .TryInvokeAsync(
                (service, callbackId, cancellationToken) =>
                service.ComputeProjectTelemetryAsync(callbackId, cancellationToken),
                cancellationToken
                )
                .ConfigureAwait(false);
        }