/// <summary>
        /// Invoked by <see cref="Cmdlet.WriteProgress(ProgressRecord)" /> to display a progress record.
        /// </summary>
        /// <param name="sourceId">
        /// Unique identifier of the source of the record. An int64 is used because typically,
        /// the 'this' pointer of the command from whence the record is originating is used, and
        /// that may be from a remote Runspace on a 64-bit machine.
        /// </param>
        /// <param name="record">
        /// The record being reported to the host.
        /// </param>
        public sealed override void WriteProgress(
            long sourceId,
            ProgressRecord record)
        {
            // Maintain old behavior if this isn't overridden.
            if (!this.SupportsWriteProgress)
            {
                this.UpdateProgress(sourceId, ProgressDetails.Create(record));
                return;
            }

            // Keep a list of progress records we write so we can automatically
            // clean them up after the pipeline ends.
            if (record.RecordType == ProgressRecordType.Completed)
            {
                this.currentProgressMessages.TryRemove(new ProgressKey(sourceId, record), out _);
            }
            else
            {
                // Adding with a value of null here because we don't actually need a dictionary. We're
                // only using ConcurrentDictionary<,> becuase there is no ConcurrentHashSet<>.
                this.currentProgressMessages.TryAdd(new ProgressKey(sourceId, record), null);
            }

            this.WriteProgressImpl(sourceId, record);
        }
Exemple #2
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="sourceId"></param>
 /// <param name="record"></param>
 public override void WriteProgress(
     long sourceId,
     ProgressRecord record)
 {
     this.UpdateProgress(
         sourceId,
         ProgressDetails.Create(record));
 }
 public override void WriteProgress(
     long sourceId,
     ProgressRecord record)
 {
     if (this.consoleHost != null)
     {
         this.consoleHost.UpdateProgress(
             sourceId,
             ProgressDetails.Create(record));
     }
 }