Esempio n. 1
0
        /// <summary>
        /// Suspends full tracking.
        /// </summary>
        /// <returns>An object that will resume full tracking when disposed.</returns>
        internal static IDisposable Suspend()
        {
            FullTracking tracking = new FullTracking();

            if (tracking._trackingMode == TrackingMode.Active)
            {
                InprocTrackingNativeMethods.SuspendTracking();
                tracking._trackingMode = TrackingMode.Suspended;
            }

            return(tracking);
        }
Esempio n. 2
0
        /// <summary>
        /// Starts full tracking.
        /// </summary>
        /// <param name="targetName">taskLoggingContext.TargetLoggingContext.Target.Name</param>
        /// <param name="taskName">taskNode.Name</param>
        /// <param name="projectRootDirectory">buildRequestEntry.ProjectRootDirectory</param>
        /// <param name="projectProperties">buildRequestEntry.RequestConfiguration.Project.PropertiesToBuildWith</param>
        /// <returns>
        /// An object that will stop full tracking when disposed.
        /// </returns>
        internal static IDisposable Track(string targetName, string taskName, string projectRootDirectory, PropertyDictionary <ProjectPropertyInstance> projectProperties)
        {
            FullTracking tracking = new FullTracking();

            ProjectPropertyInstance tlogRelativeDirectoryProperty = projectProperties[FullTrackingDirectoryPropertyName];
            string tlogRelativeDirectoryValue = null;

            if (tlogRelativeDirectoryProperty != null)
            {
                tlogRelativeDirectoryValue = tlogRelativeDirectoryProperty.EvaluatedValue;
            }

            if (!String.IsNullOrEmpty(tlogRelativeDirectoryValue))
            {
                tracking._taskName      = GenerateUniqueTaskName(targetName, taskName);
                tracking._tlogDirectory = Path.Combine(projectRootDirectory, tlogRelativeDirectoryValue);
                InprocTrackingNativeMethods.StartTrackingContext(tracking._tlogDirectory, tracking._taskName);
                tracking._trackingMode = TrackingMode.Active;
            }

            return(tracking);
        }
Esempio n. 3
0
        /// <summary>
        /// Disposes the FullTracking object, causing full tracking to end, or resume,
        /// depending on how this object was created.
        /// </summary>
        protected virtual void Dispose(bool disposing)
        {
            if (disposing)
            {
                switch (_trackingMode)
                {
                case TrackingMode.Active:
                    // Stop tracking
                    InprocTrackingNativeMethods.WriteContextTLogs(_tlogDirectory, _taskName);
                    InprocTrackingNativeMethods.EndTrackingContext();
                    break;

                case TrackingMode.Suspended:
                    // Stop suspending tracking
                    InprocTrackingNativeMethods.ResumeTracking();
                    break;

                default:
                    // nothing to do here if we weren't actively tracking or suspended.
                    break;
                }
            }
        }
Esempio n. 4
0
 public static void WriteContextTLogs(string intermediateDirectory, string taskName)
 {
     InprocTrackingNativeMethods.WriteContextTLogs(intermediateDirectory, taskName);
 }
Esempio n. 5
0
 /// <summary>
 /// Temporarily suspend tracking of file accesses in the current tracking context.
 /// </summary>
 public static void SuspendTracking()
 {
     InprocTrackingNativeMethods.SuspendTracking();
 }
Esempio n. 6
0
 /// <summary>
 /// Stop tracking file accesses and get rid of the current tracking contexts.
 /// </summary>
 public static void StopTrackingAndCleanup()
 {
     InprocTrackingNativeMethods.StopTrackingAndCleanup();
 }
Esempio n. 7
0
 /// <summary>
 /// Starts tracking file accesses, using the rooting marker in the response file provided.  To
 /// automatically generate a response file given a rooting marker, call
 /// FileTracker.CreateRootingMarkerResponseFile.
 /// </summary>
 /// <param name="intermediateDirectory">The directory into which to write the tracking log files</param>
 /// <param name="taskName">The name of the task calling this function, used to determine the
 /// names of the tracking log files</param>
 public static void StartTrackingContextWithRoot(string intermediateDirectory, string taskName, string rootMarkerResponseFile)
 {
     InprocTrackingNativeMethods.StartTrackingContextWithRoot(intermediateDirectory, taskName, rootMarkerResponseFile);
 }
Esempio n. 8
0
 /// <summary>
 /// Starts tracking file accesses.
 /// </summary>
 /// <param name="intermediateDirectory">The directory into which to write the tracking log files</param>
 /// <param name="taskName">The name of the task calling this function, used to determine the
 /// names of the tracking log files</param>
 public static void StartTrackingContext(string intermediateDirectory, string taskName)
 {
     InprocTrackingNativeMethods.StartTrackingContext(intermediateDirectory, taskName);
 }
Esempio n. 9
0
 /// <summary>
 /// Set the global thread count, and assign that count to the current thread.
 /// </summary>
 public static void SetThreadCount(int threadCount)
 {
     InprocTrackingNativeMethods.SetThreadCount(threadCount);
 }
Esempio n. 10
0
 /// <summary>
 /// Resume tracking file accesses in the current tracking context.
 /// </summary>
 public static void ResumeTracking()
 {
     InprocTrackingNativeMethods.ResumeTracking();
 }
Esempio n. 11
0
 /// <summary>
 /// Stops tracking file accesses.
 /// </summary>
 public static void EndTrackingContext()
 {
     InprocTrackingNativeMethods.EndTrackingContext();
 }