StackTrace.GetFrames Método

Definição

Retorna uma cópia de todos os quadros de pilha no rastreamento de pilha atual.Returns a copy of all stack frames in the current stack trace.

public:
 cli::array <System::Diagnostics::StackFrame ^> ^ GetFrames();
public:
 virtual cli::array <System::Diagnostics::StackFrame ^> ^ GetFrames();
public System.Diagnostics.StackFrame[] GetFrames ();
public virtual System.Diagnostics.StackFrame[] GetFrames ();
public virtual System.Diagnostics.StackFrame?[] GetFrames ();
[System.Runtime.InteropServices.ComVisible(false)]
public virtual System.Diagnostics.StackFrame[] GetFrames ();
member this.GetFrames : unit -> System.Diagnostics.StackFrame[]
abstract member GetFrames : unit -> System.Diagnostics.StackFrame[]
override this.GetFrames : unit -> System.Diagnostics.StackFrame[]
[<System.Runtime.InteropServices.ComVisible(false)>]
abstract member GetFrames : unit -> System.Diagnostics.StackFrame[]
override this.GetFrames : unit -> System.Diagnostics.StackFrame[]
Public Function GetFrames () As StackFrame()
Public Overridable Function GetFrames () As StackFrame()

Retornos

StackFrame[]

Uma matriz do tipo StackFrame que representa as chamadas de função no rastreamento de pilha.An array of type StackFrame representing the function calls in the stack trace.

Atributos

Exemplos

O exemplo de código a seguir demonstra a enumeração dos quadros em um StackTrace .The following code example demonstrates enumerating the frames in a StackTrace.

StackTrace^ st = gcnew StackTrace( 1,true );
array<StackFrame^>^stFrames = st->GetFrames();
for ( int i; i < stFrames->Length; i++ )
{
   StackFrame^ sf = stFrames[ i ];
   Console::WriteLine( "Method: {0}", sf->GetMethod() );

}
StackTrace st = new StackTrace(1, true);
StackFrame [] stFrames = st.GetFrames();

foreach(StackFrame sf in stFrames )
{
   Console.WriteLine("Method: {0}", sf.GetMethod() );
}
Dim strace As New StackTrace(1, True)
Dim stFrames As StackFrame() = strace.GetFrames()

Dim sf As StackFrame
For Each sf In  stFrames
   Console.WriteLine("Method: {0}", sf.GetMethod())
Next sf

Comentários

Use a StackFrame matriz retornada para enumerar e examinar as chamadas de função no StackTrace .Use the returned StackFrame array to enumerate and examine function calls in the StackTrace. O comprimento da matriz retornada é igual ao valor da FrameCount propriedade.The length of the returned array is equal to the FrameCount property value.

Os StackFrame elementos da matriz estão em ordem cronológica inversa.The StackFrame array elements are in reverse chronological order. O StackFrame índice de matriz at 0 representa a chamada de função mais recente no rastreamento de pilha e o último quadro enviado para a pilha de chamadas.The StackFrame at array index 0 represents the most recent function call in the stack trace and the last frame pushed onto the call stack. O StackFrame índice de matriz em FrameCount menos 1 representa a chamada de função mais antiga no rastreamento de pilha e o primeiro quadro enviado por push para a pilha de chamadas.The StackFrame at array index FrameCount minus 1 represents the oldest function call in the stack trace and the first frame pushed onto the call stack.

Use o GetFrames método para obter todos os quadros de pilha em um rastreamento de pilha; use o GetFrame método para obter um quadro de pilha específico em um rastreamento de pilha.Use the GetFrames method to obtain all stack frames in a stack trace; use the GetFrame method to obtain a specific stack frame in a stack trace. Os StackFrame índices são ordenados de forma semelhante aos dois métodos.The StackFrame indexes are ordered alike by the two methods. Por exemplo, o StackFrame no índice 0 na matriz retornada por GetFrames é equivalente ao StackFrame retornado por GetFrame com um índice de entrada de 0.For example, the StackFrame at index 0 in the array returned by GetFrames is equivalent to the StackFrame returned by GetFrame with an input index of 0.

Aplica-se a

Confira também