Debug.Flush 메서드

정의

출력 버퍼를 플러시하고 버퍼링된 데이터가 Listeners 컬렉션에 쓰여지도록 합니다.

public:
 static void Flush();
[System.Diagnostics.Conditional("DEBUG")]
public static void Flush ();
[<System.Diagnostics.Conditional("DEBUG")>]
static member Flush : unit -> unit
Public Shared Sub Flush ()
특성

예제

다음 예제에서는 명명myTextListener된 .TextWriterTraceListener myTextListener는 호출 myFileStreamFileStream 사용하여 이름이 지정된 TestFile.txt파일에 씁니다. 이 예제에서는 스트림을 만들고, 파일이 있는 경우 파일을 열거나, 새 스트림을 만들고, 한 줄의 텍스트를 파일에 쓴 다음, 출력을 플러시하고 닫습니다.

// Specify /DDEBUG when compiling.

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

void main()
{
     #if defined(DEBUG)
    // Create a new stream object for an output file named TestFile.txt.
    FileStream^ myFileStream = 
        gcnew FileStream( "TestFile.txt", FileMode::Append );
   
    // Add the stream object to the trace listeners.
    TextWriterTraceListener^ myTextListener = 
        gcnew TextWriterTraceListener( myFileStream );
    Debug::Listeners->Add( myTextListener );
   
    // Write output to the file.
    Debug::WriteLine( "Test output" );
   
    // Flush and close the output stream.
    Debug::Flush();
    Debug::Close();
    #endif
}
// Specify /d:DEBUG when compiling.

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

class Test
{
    static void Main()
    {
        // Create a new stream object for an output file named TestFile.txt.
        using (FileStream myFileStream =
            new FileStream("TestFile.txt", FileMode.Append))
        {
            // Add the stream object to the trace listeners.
            TextWriterTraceListener myTextListener =
                new TextWriterTraceListener(myFileStream);
            Debug.Listeners.Add(myTextListener);

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

            // Flush and close the output stream.
            Debug.Flush();
            Debug.Close();
        }
    }
}
' Specify /d:DEBUG=True when compiling.

Imports System.IO
Imports System.Diagnostics

Class Test
    
    Shared Sub Main()
    
        ' Create a new stream object for an output file named TestFile.txt.
        Using myFileStream As New FileStream("TestFile.txt", FileMode.Append)
        
            ' Add the stream object to the trace listeners. 
            Dim myTextListener As New TextWriterTraceListener(myFileStream)
            Debug.Listeners.Add(myTextListener)
            
            ' Write output to the file.
            Debug.WriteLine("Test output")
            
            ' Flush and close the output stream.
            Debug.Flush()
            Debug.Close()
        
        End Using
        
    End Sub

End Class

설명

명시적으로 호출하거나 Close을 호출 Flush 하지 않는 한 스트림을 플러시해도 기본 인코더가 플러시되지 않습니다. true 설정 AutoFlush 은 데이터가 버퍼에서 스트림으로 플러시되지만 인코더 상태가 플러시되지 않음을 의미합니다. 이렇게 하면 인코더가 다음 문자 블록을 올바르게 인코딩할 수 있도록 해당 상태(부분 문자)를 유지할 수 있습니다. 이 시나리오는 인코더가 인접한 문자 또는 문자를 받은 후에만 특정 문자를 인코딩할 수 있는 UTF8 및 UTF7에 영향을 줍니다.

적용 대상

추가 정보