private bool PostTrackingRecord(TrackingParticipant participant, RuntimeTrackingProfile runtimeProfile) { TrackingRecord originalRecord = _provider._pendingTrackingRecords[_currentRecord]; _currentRecord++; bool isSuccessful = false; try { TrackingRecord preparedRecord = null; bool shouldClone = _provider._trackingParticipants.Count > 1; if (runtimeProfile == null) { preparedRecord = shouldClone ? originalRecord.Clone() : originalRecord; } else { preparedRecord = runtimeProfile.Match(originalRecord, shouldClone); } if (preparedRecord != null) { IAsyncResult result = participant.BeginTrack(preparedRecord, _timeoutHelper.RemainingTime(), PrepareAsyncCompletion(s_trackingCompleteCallback), this); if (TD.TrackingRecordRaisedIsEnabled()) { TD.TrackingRecordRaised(preparedRecord.ToString(), participant.GetType().ToString()); } if (result.CompletedSynchronously) { participant.EndTrack(result); } else { isSuccessful = true; return(false); } } isSuccessful = true; } finally { if (!isSuccessful) { _provider.ClearPendingRecords(); } } return(true); }
private static bool OnTrackingComplete(IAsyncResult result) { Fx.Assert(!result.CompletedSynchronously, "TrackingAsyncResult.OnTrackingComplete should not get called with a result that is CompletedSynchronously"); FlushPendingRecordsAsyncResult thisPtr = (FlushPendingRecordsAsyncResult)result.AsyncState; TrackingParticipant participant = thisPtr._provider._trackingParticipants[thisPtr._currentParticipant]; bool isSuccessful = false; try { participant.EndTrack(result); isSuccessful = true; } finally { if (!isSuccessful) { thisPtr._provider.ClearPendingRecords(); } } return(thisPtr.RunLoop()); }