DataCollection.MarkProfile Method

The MarkProfile method inserts a profile mark in the .vsp file. Profiling for the thread containing the MarkProfile function must be ON for the mark to be inserted.

Namespace:  Microsoft.VisualStudio.Profiler
Assembly:  Microsoft.VisualStudio.Profiler (in Microsoft.VisualStudio.Profiler.dll)

public static MarkOperationResult MarkProfile(
	int markId
)

Parameters

markId
Type: Int32

The marker to insert. The marker must be greater than or equal to 0 (zero).

Return Value

Type: Microsoft.VisualStudio.Profiler.MarkOperationResult
The return value, MarkOperationResult, is an enum.

The mark value is inserted into the .vsp file each time the code runs if the thread containing the MarkProfile function is being profiled. You can call MarkProfile multiple times.

Profile marks are global in scope. For example, a profile mark inserted in one thread can be used to mark the start or end of a data segment in any thread in the .vsp file.

The profiling state for the thread that contains the mark profile function must be on when marks and comments inserted with the Mark command or with API functions (CommentMarkAtProfile, CommentMarkProfile, or MarkProfile).

Important noteImportant

MarkProfile methods should be used with instrumentation only.

The following example illustrates the MarkProfile method.

        public void ExerciseMarkProfile()
        {
            // Declare and initialize variables to pass to 
            // MarkProfile.  The values of these parameters 
            // are assigned based on the needs of the code;
            // and for the sake of simplicity in this example, 
            // the variables are assigned arbitrary values.
            int markId = 03;

            // Declare enumeration to hold return value of 
            // call to MarkProfile.
            MarkOperationResult markResult;

            markResult = DataCollection.MarkProfile(
                markId);

            Console.WriteLine("MarkProfile returned {0}", markResult);
        }

Show: