Exemple #1
0
        private void PostToOutput(DesignTimeInputsDelta delta)
        {
            _version++;
            ImmutableDictionary <NamedIdentity, IComparable> dataSources = ImmutableDictionary <NamedIdentity, IComparable> .Empty.Add(DataSourceKey, DataSourceVersion);

            _broadcastBlock.Post(new ProjectVersionedValue <DesignTimeInputsDelta>(delta, dataSources));
        }
 private void PublishSnapshot(DesignTimeInputSnapshot snapshot)
 {
     _version++;
     _broadcastBlock.Post(new ProjectVersionedValue <DesignTimeInputSnapshot>(
                              snapshot,
                              Empty.ProjectValueVersions.Add(DataSourceKey, _version)));
 }
        private void TryUpdateSnapshot(Func <DependenciesSnapshot, DependenciesSnapshot> updateFunc, CancellationToken token = default)
        {
            lock (_snapshotLock)
            {
                DependenciesSnapshot updatedSnapshot = updateFunc(_currentSnapshot);

                if (ReferenceEquals(_currentSnapshot, updatedSnapshot))
                {
                    return;
                }

                _currentSnapshot = updatedSnapshot;
            }

            // Conflate rapid snapshot updates by debouncing events over a short window.
            // This reduces the frequency of tree updates with minimal perceived latency.
            _dependenciesUpdateScheduler.ScheduleAsyncTask(
                ct =>
            {
                if (ct.IsCancellationRequested || IsDisposing || IsDisposed)
                {
                    return(Task.FromCanceled(ct));
                }

                // Always publish the latest snapshot
                IDependenciesSnapshot snapshot = _currentSnapshot;

                var events = new SnapshotChangedEventArgs(snapshot, ct);
                _snapshotChangedSource.Post(events);
                SnapshotChanged?.Invoke(this, events);

                return(Task.CompletedTask);
            }, token);
        }
        private void PostToOutput(string[] file)
        {
            _version++;
            ImmutableDictionary <NamedIdentity, IComparable> dataSources = ImmutableDictionary <NamedIdentity, IComparable> .Empty.Add(DataSourceKey, DataSourceVersion);

            _broadcastBlock.Post(new ProjectVersionedValue <string[]>(file, dataSources));
        }
Exemple #5
0
 private void PublishFiles(string[] files)
 {
     _version++;
     _broadcastBlock.Post(new ProjectVersionedValue <string[]>(
                              files,
                              Empty.ProjectValueVersions.Add(DataSourceKey, _version)));
 }
        protected async Task FinishUpdateAsync(ILaunchSettings newSnapshot, bool ensureProfileProperty)
        {
            CurrentSnapshot = newSnapshot;

            if (ensureProfileProperty)
            {
                ProjectDebugger props = await _commonProjectServices.ActiveConfiguredProjectProperties.GetProjectDebuggerPropertiesAsync();

                if (await props.ActiveDebugProfile.GetValueAsync() is IEnumValue activeProfileVal)
                {
                    if (newSnapshot.ActiveProfile?.Name != null && !string.Equals(newSnapshot.ActiveProfile?.Name, activeProfileVal.Name))
                    {
                        await props.ActiveDebugProfile.SetValueAsync(newSnapshot.ActiveProfile.Name);
                    }
                }
            }

            _broadcastBlock?.Post(newSnapshot);
        }
Exemple #7
0
            /// <summary>
            /// Executes <paramref name="updateFunc"/> on the current snapshot within a lock. If a new snapshot
            /// object is returned, <see cref="Current"/> is updated and the update is posted to <see cref="Source"/>.
            /// </summary>
            /// <returns>The updated snapshot, or <see langword="null" /> if no update occurred.</returns>
            public DependenciesSnapshot?TryUpdate(Func <DependenciesSnapshot, DependenciesSnapshot> updateFunc, CancellationToken token = default)
            {
                if (_isDisposed != 0)
                {
                    throw new ObjectDisposedException(nameof(SnapshotUpdater));
                }

                DependenciesSnapshot updatedSnapshot;

                lock (_lock)
                {
                    updatedSnapshot = updateFunc(_currentSnapshot);

                    if (ReferenceEquals(_currentSnapshot, updatedSnapshot))
                    {
                        return(null);
                    }

                    _currentSnapshot = updatedSnapshot;
                }

                // Conflate rapid snapshot updates by debouncing events over a short window.
                // This reduces the frequency of tree updates with minimal perceived latency.
                _ = _debounce.ScheduleAsyncTask(
                    ct =>
                {
                    if (ct.IsCancellationRequested || _isDisposed != 0)
                    {
                        return(Task.FromCanceled(ct));
                    }

                    // Always publish the latest snapshot
                    DependenciesSnapshot snapshot = _currentSnapshot;
                    _source.Post(new SnapshotChangedEventArgs(snapshot, ct));

                    return(Task.CompletedTask);
                }, token);

                return(updatedSnapshot);
            }
        /// <summary>
        /// Helper function to set the new snapshot and post the changes to consumers.
        /// </summary>
        protected void FinishUpdate(ILaunchSettings newSnapshot)
        {
            CurrentSnapshot = newSnapshot;

            _broadcastBlock?.Post(newSnapshot);
        }