We recommend using Visual Studio 2017
This documentation is archived and is not being maintained.

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
public static MarkOperationResult MarkProfile (
	int markId
public static function MarkProfile (
	markId : int
) : MarkOperationResult



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

Return Value

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).


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(

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