Share via


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)

Syntax

'Declaration
Public Shared Function StartProfile ( _
    profileLevel As ProfileLevel, _
    elementId As UInteger _
) As ProfileOperationResult
public static ProfileOperationResult StartProfile(
    ProfileLevel profileLevel,
    uint elementId
)
public:
static ProfileOperationResult StartProfile(
    ProfileLevel profileLevel, 
    unsigned int elementId
)
static member StartProfile : 
        profileLevel:ProfileLevel * 
        elementId:uint32 -> ProfileOperationResult
public static function StartProfile(
    profileLevel : ProfileLevel, 
    elementId : uint
) : ProfileOperationResult

Parameters

  • elementId
    Type: System.UInt32

    The process or thread identifier generated by the system.

Return Value

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

Remarks

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.

Examples

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);
        }

.NET Framework Security

See Also

Reference

DataCollection Class

Microsoft.VisualStudio.Profiler Namespace