コード例 #1
0
ファイル: TrackingProvider.cs プロジェクト: dox0/DotNet471RS3
        public void FlushPendingRecords(TimeSpan timeout)
        {
            try
            {
                if (this.HasPendingRecords)
                {
                    TimeoutHelper helper = new TimeoutHelper(timeout);
                    for (int i = 0; i < this.trackingParticipants.Count; i++)
                    {
                        TrackingParticipant    participant    = this.trackingParticipants[i];
                        RuntimeTrackingProfile runtimeProfile = GetRuntimeTrackingProfile(participant);

                        // HasPendingRecords can be true for the sole purpose of populating our initial profiles, so check again here
                        if (this.pendingTrackingRecords != null)
                        {
                            for (int j = 0; j < this.pendingTrackingRecords.Count; j++)
                            {
                                TrackingRecord currentRecord = this.pendingTrackingRecords[j];
                                Fx.Assert(currentRecord != null, "We should never come across a null context.");

                                TrackingRecord preparedRecord = null;
                                bool           shouldClone    = this.trackingParticipants.Count > 1;
                                if (runtimeProfile == null)
                                {
                                    preparedRecord = shouldClone ? currentRecord.Clone() : currentRecord;
                                }
                                else
                                {
                                    preparedRecord = runtimeProfile.Match(currentRecord, shouldClone);
                                }

                                if (preparedRecord != null)
                                {
                                    participant.Track(preparedRecord, helper.RemainingTime());
                                    if (TD.TrackingRecordRaisedIsEnabled())
                                    {
                                        TD.TrackingRecordRaised(preparedRecord.ToString(), participant.GetType().ToString());
                                    }
                                }
                            }
                        }
                    }
                }
            }
            finally
            {
                // Note that if we fail to track yet the workflow manages to recover
                // we will attempt to track those records again.
                ClearPendingRecords();
            }
        }
コード例 #2
0
 public void FlushPendingRecords(TimeSpan timeout)
 {
     try
     {
         if (this.HasPendingRecords)
         {
             TimeoutHelper helper = new TimeoutHelper(timeout);
             for (int i = 0; i < this.trackingParticipants.Count; i++)
             {
                 TrackingParticipant    participant            = this.trackingParticipants[i];
                 RuntimeTrackingProfile runtimeTrackingProfile = this.GetRuntimeTrackingProfile(participant);
                 if (this.pendingTrackingRecords != null)
                 {
                     for (int j = 0; j < this.pendingTrackingRecords.Count; j++)
                     {
                         TrackingRecord record      = this.pendingTrackingRecords[j];
                         TrackingRecord record2     = null;
                         bool           shouldClone = this.trackingParticipants.Count > 1;
                         if (runtimeTrackingProfile == null)
                         {
                             record2 = shouldClone ? record.Clone() : record;
                         }
                         else
                         {
                             record2 = runtimeTrackingProfile.Match(record, shouldClone);
                         }
                         if (record2 != null)
                         {
                             participant.Track(record2, helper.RemainingTime());
                             if (TD.TrackingRecordRaisedIsEnabled())
                             {
                                 TD.TrackingRecordRaised(record2.ToString(), participant.GetType().ToString());
                             }
                         }
                     }
                 }
             }
         }
     }
     finally
     {
         this.ClearPendingRecords();
     }
 }