/// <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);
        }
예제 #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));
     }
 }
 void IConsoleHost.UpdateProgress(
     long sourceId,
     ProgressDetails progressDetails)
 {
     this.syncContext.Post(
         (d) =>
     {
         this.wrappedConsoleHost.UpdateProgress(
             sourceId,
             progressDetails);
     },
         null);
 }
예제 #5
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);
예제 #6
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)
 {
 }
 void IConsoleHost.UpdateProgress(
     long sourceId, 
     ProgressDetails progressDetails)
 {
     this.syncContext.Post(
         (d) =>
         {
             this.wrappedConsoleHost.UpdateProgress(
                 sourceId,
                 progressDetails);
         },
         null);
 }
 void IConsoleHost.UpdateProgress(long sourceId, ProgressDetails progressDetails)
 {
     //throw new NotImplementedException();
 }