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

DataCollection.StartProfile Method

The StartProfile method sets the counter to 1 (on) for the specified profiling level.

Namespace: Microsoft.VisualStudio.Profiler
Assembly: Microsoft.VisualStudio.Profiler (in microsoft.visualstudio.profiler.dll)

public static ProfileOperationResult StartProfile (
	ProfileLevel profileLevel,
	uint elementId
)
public static ProfileOperationResult StartProfile (
	ProfileLevel profileLevel, 
	UInt32 elementId
)
public static function StartProfile (
	profileLevel : ProfileLevel, 
	elementId : uint
) : ProfileOperationResult

Parameters

profileLevel

Identifies the execution level of the identifier specified in elementId.

elementId

The process or thread identifier generated by the system.

Return Value

The return value, ProfileOperationResult, is an enum.

StartProfile and StopProfile control the Start/Stop state for the profiling level. The default initial value of Start/Stop is 1. The initial value can be changed in the registry. Each call to StartProfile sets Start/Stop to 1; each call to StopProfile sets Start/Stop to 0.

When the Start/Stop is greater than 0, the Start/Stop state for the level is ON. When it is less than or equal to 0, the Start/Stop state is OFF.

When the Start/Stop state and the Suspend/Resume state are both ON, the profiling state for the level is ON. For a thread to be profiled, the global, process, and thread level states for the thread must be ON.

The following example illustrates the StartProfile method.

        public void ExerciseStartProfile()
        {
            // StartProfile and StopProfile control the
            // Start/Stop state for the profiling level. 
            // The default initial value of Start/Stop is 1. 
            // The initial value can be changed in the registry. 
            // Each call to StartProfile sets Start/Stop to 1; 
            // each call to StopProfile sets it to 0. 
            
            // Declare enumeration to hold return value of 
            // the call to StartProfile.
            ProfileOperationResult profileResult;

            profileResult = DataCollection.StartProfile(
                ProfileLevel.Global,
                DataCollection.CurrentId);

            Console.WriteLine("StartProfile returned {0}", profileResult);
        }
Show: