Close Método
Este artículo se tradujo automáticamente. Para ver el artículo en inglés, active la casilla Inglés. Además, puede mostrar el texto en inglés en una ventana emergente si mueve el puntero del mouse sobre el texto.
Traducción
Inglés

Trace::Close (Método) ()

 

Vacía el búfer de salida y, a continuación, cierra los Listeners.

Espacio de nombres:   System.Diagnostics
Ensamblado:  System (en System.dll)

public:
[ConditionalAttribute("TRACE")]
static void Close()

Use this method when the output is going to a file, such as to the T:System.Diagnostics.TextWriterTraceListener.

Flushing the stream will not flush its underlying encoder unless you explicitly call M:System.Diagnostics.Trace.Flush or M:System.Diagnostics.Trace.Close. Setting P:System.Diagnostics.Trace.AutoFlush to true means that data will be flushed from the buffer to the stream, but the encoder state will not be flushed. This allows the encoder to keep its state (partial characters) so that it can encode the next block of characters correctly. This scenario affects UTF8 and UTF7 where certain characters can only be encoded after the encoder receives the adjacent character or characters.

The following example creates a T:System.Diagnostics.TextWriterTraceListener named myTextListener. myTextListener uses a T:System.IO.StreamWriter called myOutputWriter to write to a file named TestFile.txt. The example creates the file, stream and text writer, writes one line of text to the file, and then flushes and closes the output.

// Specify /DTRACE when compiling.

#using <System.dll>
using namespace System;
using namespace System::IO;
using namespace System::Diagnostics;

void main()
{
     #if defined(TRACE)
    // Create a file for output named TestFile.txt.
    FileStream^ myFileStream = 
        gcnew FileStream( "TestFile.txt", FileMode::Append );

    // Create a new text writer using the output stream 
    // and add it to the trace listeners.
    TextWriterTraceListener^ myTextListener = 
        gcnew TextWriterTraceListener( myFileStream );
    Trace::Listeners->Add( myTextListener );

    // Write output to the file.
    Trace::WriteLine( "Test output" );

    // Flush and close the output stream.
    Trace::Flush();
    Trace::Close();
    #endif
}

SecurityPermission

for operating with unmanaged code. Security action: F:System.Security.Permissions.SecurityAction.Demand. Associated enumeration: F:System.Security.Permissions.SecurityPermissionFlag.UnmanagedCode

.NET Framework
Disponible desde 1.1
Volver al principio
Mostrar:
© 2016 Microsoft