Share via


DataCollection.StopProfile Method

The StopProfile method sets the counter to 0 (off) for the specified profiling level.

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

Syntax

'Declaration
Public Shared Function StopProfile ( _
    profileLevel As ProfileLevel, _
    elementId As UInteger _
) As ProfileOperationResult
public static ProfileOperationResult StopProfile(
    ProfileLevel profileLevel,
    uint elementId
)
public:
static ProfileOperationResult StopProfile(
    ProfileLevel profileLevel, 
    unsigned int elementId
)
static member StopProfile : 
        profileLevel:ProfileLevel * 
        elementId:uint32 -> ProfileOperationResult
public static function StopProfile(
    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 it 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 StopProfile method. The example assumes that a call to the StartProfile method has been made for the same thread or process identified by DataCollection.CurrentId.

        public void ExerciseStopProfile()
        {
            // 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 result of call 
            // to StopProfile.
            ProfileOperationResult profileResult;

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

            Console.WriteLine("StopProfile returned {0}", profileResult);
        }

.NET Framework Security

See Also

Reference

DataCollection Class

Microsoft.VisualStudio.Profiler Namespace