DataCollection.NameProfile Method (String, ProfileLevel, UInt32)

 

The NameProfile method assigns a string to the specified process or thread.

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

Syntax

public static NameOperationResult NameProfile(
    string profileName,
    ProfileLevel profileLevel,
    uint elementId
)
public:
static NameOperationResult NameProfile(
    String^ profileName,
    ProfileLevel profileLevel,
    unsigned int elementId
)
static member NameProfile : 
        profileName:string *
        profileLevel:ProfileLevel *
        elementId:uint32 -> NameOperationResult
Public Shared Function NameProfile (
    profileName As String,
    profileLevel As ProfileLevel,
    elementId As UInteger
) As NameOperationResult

Parameters

  • profileName
    Type: System.String

    The name of the profiling element.

  • elementId
    Type: System.UInt32

    Profiling level identifier. Use the process or thread identifier that is generated by the system.

Return Value

Type: Microsoft.VisualStudio.Profiler.NameOperationResult

The return value, NameOperationResult, is an enum.

Remarks

Only one name can be assigned to each process or thread. After a profiling element is named, subsequent calls to NameProfile for that element are ignored.

If the same name is given to different threads or processes, the report will include data from all elements at that level with that name.

If you specify a process or thread other than the current one, you must ensure that it has initialized and started running before you name it. Otherwise, the NameProfile method fails. Both the CreateProcess() and CreateThread() API functions can return before the thread or process is initialized.

Examples

The following example illustrates the NameProfile method.

public void ExerciseNameProfile()
{
    // Create and initalize variables to pass to 
    // ExerciseNameProfile.  The values of this 
    // parameter is based on the needs of the code;
    // and for the sake of simplicity in this example, 
    // the variable is assigned 
    // an arbitrary value.
    string profileName = "ExerciseNameProfile";

    // Declare enumeration to hold result of call to 
    // ExerciseNameProfle.
    NameOperationResult nameResult;

    nameResult =  DataCollection.NameProfile(
        profileName,
        ProfileLevel.Global,
        DataCollection.CurrentId);

    Console.WriteLine("NameProfile returned {0}", nameResult);
}

See Also

DataCollection Class
Microsoft.VisualStudio.Profiler Namespace

Return to top