DataCollection.NameProfile Method
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
'Declaration
Public Shared Function NameProfile ( _
profileName As String, _
profileLevel As ProfileLevel, _
elementId As UInteger _
) As NameOperationResult
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 static function NameProfile(
profileName : String,
profileLevel : ProfileLevel,
elementId : uint
) : NameOperationResult
Parameters
- profileName
Type: System.String
The name of the profiling element.
- profileLevel
Type: Microsoft.VisualStudio.Profiler.ProfileLevel
Identifies the execution level of the identifier specified in elementId.
- 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);
}
.NET Framework Security
- Full trust for the immediate caller. This member cannot be used by partially trusted code. For more information, see Using Libraries from Partially Trusted Code.