DataCollection.StartProfile Method (ProfileLevel, UInt32)

 

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

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 Shared Function StartProfile (
    profileLevel As ProfileLevel,
    elementId As UInteger
) As 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);
}

See Also

DataCollection Class
Microsoft.VisualStudio.Profiler Namespace

Return to top