Questo articolo è stato tradotto automaticamente. Per visualizzare l'articolo in inglese, selezionare la casella di controllo Inglese. È possibile anche visualizzare il testo inglese in una finestra popup posizionando il puntatore del mouse sopra il testo.
Traduzione
Inglese

Metodo Trace.Flush ()

 

Svuota il buffer di output e determina la scrittura dei dati del buffer in Listeners.

Spazio dei nomi:   System.Diagnostics
Assembly:  System (in System.dll)

[ConditionalAttribute("TRACE")]
public static void Flush()

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 /d:TRACE when compiling.

using System;
using System.IO;
using System.Diagnostics;

class Test
{
    static void Main()
    {
        // Create a file for output named TestFile.txt.
        using (FileStream myFileStream = 
            new FileStream("TestFile.txt", FileMode.Append))
        {
            // Create a new text writer using the output stream 
            // and add it to the trace listeners.
            TextWriterTraceListener myTextListener = 
                new 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();
        }
    }
}

.NET Framework
Disponibile da 1.1
Torna all'inizio
Mostra: