Beispiel #1
0
        /// <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);
        }
Beispiel #2
0
 /// <summary>
 /// Sends a progress update event to the user.
 /// </summary>
 /// <param name="sourceId">The source ID of the progress event.</param>
 /// <param name="progressDetails">The details of the activity's current progress.</param>
 protected override void UpdateProgress(
     long sourceId,
     ProgressDetails progressDetails)
 {
     // TODO: Send a new message.
 }
Beispiel #3
0
 /// <summary>
 /// Sends a progress update event to the user.
 /// </summary>
 /// <param name="sourceId">The source ID of the progress event.</param>
 /// <param name="progressDetails">The details of the activity's current progress.</param>
 protected override void UpdateProgress(
     long sourceId,
     ProgressDetails progressDetails)
 {
 }
Beispiel #4
0
 /// <summary>
 /// Sends a progress update event to the user.
 /// </summary>
 /// <param name="sourceId">The source ID of the progress event.</param>
 /// <param name="progressDetails">The details of the activity's current progress.</param>
 protected abstract void UpdateProgress(
     long sourceId,
     ProgressDetails progressDetails);