次の方法で共有


DataCollection.NameProfile メソッド

NameProfile メソッドは、指定したプロセスまたはスレッドに文字列を割り当てます。

名前空間:  Microsoft.VisualStudio.Profiler
アセンブリ:  Microsoft.VisualStudio.Profiler (Microsoft.VisualStudio.Profiler.dll 内)

構文

'宣言
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

パラメーター

  • profileName
    型: System.String
    プロファイル要素の名前。
  • elementId
    型: System.UInt32
    プロファイル レベル ID。システムにより生成されたプロセス ID またはスレッド ID を使用します。

戻り値

型: Microsoft.VisualStudio.Profiler.NameOperationResult
戻り値の NameOperationResult は列挙型です。

解説

各プロセスまたは各スレッドには、名前を 1 つのみ割り当てることができます。 プロファイル要素に名前を付けた後で、その要素の NameProfile を呼び出しても、無視されます。

異なるスレッドまたはプロセスに同じ名前が指定されている場合、その名前を持つそのレベルの全要素のデータがレポートに含まれます。

現在のプロセスまたはスレッド以外のプロセスまたはスレッドを指定した場合、それが初期化され実行が開始されていることを確認した後で名前を付ける必要があります。 初期化されず、実行が開始されていない場合、NameProfile メソッドは失敗します。 スレッドまたはプロセスが初期化される前でも、CreateProcess() API 関数および CreateThread() API 関数の両方は値を返します。

次に NameProfile メソッドの例を示します。

        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 セキュリティ

  • 直前の呼び出し元に対する完全な信頼。 このメンバーは、部分的に信頼されているコードから使用することはできません。 詳細については、「部分信頼コードからのライブラリの使用」を参照してください。

参照

参照

DataCollection クラス

Microsoft.VisualStudio.Profiler 名前空間