Trace.Flush 메서드
정의
중요
일부 정보는 릴리스되기 전에 상당 부분 수정될 수 있는 시험판 제품과 관련이 있습니다. Microsoft는 여기에 제공된 정보에 대해 어떠한 명시적이거나 묵시적인 보증도 하지 않습니다.
출력 버퍼를 플러시하고 버퍼링된 데이터가 .에 Listeners기록되도록 합니다.
public:
static void Flush();
[System.Diagnostics.Conditional("TRACE")]
public static void Flush();
[<System.Diagnostics.Conditional("TRACE")>]
static member Flush : unit -> unit
Public Shared Sub Flush ()
- 특성
예제
다음 예제에서는 명명TextWriterTraceListener된 .myTextListener
myTextListener는 호출 StreamWriter 을 myOutputWriter 사용하여 .라는 TestFile.txt파일에 씁니다. 이 예제에서는 파일, 스트림 및 텍스트 기록기를 만들고, 한 줄의 텍스트를 파일에 쓴 다음, 출력을 플러시하고 닫습니다.
// 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();
}
}
}
' Specify /d:TRACE=True when compiling.
Imports System.IO
Imports System.Diagnostics
Class Test
Shared Sub Main()
' Create a file for output named TestFile.txt.
Using myFileStream As New FileStream("TestFile.txt", FileMode.Append)
' Create a new text writer using the output stream
' and add it to the trace listeners.
Dim myTextListener As 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()
End Using
End Sub
End Class
설명
명시적으로 호출 Flush 하거나 Close플러시하지 않는 한 스트림을 플러시하면 해당 기본 인코더가 플러시되지 않습니다.
AutoFlush 로 설정 true 하면 데이터가 버퍼에서 스트림으로 플러시되지만 인코더 상태는 플러시되지 않습니다. 이렇게 하면 인코더가 다음 문자 블록을 올바르게 인코딩할 수 있도록 해당 상태(부분 문자)를 유지할 수 있습니다. 이 시나리오는 인코더가 인접한 문자 또는 문자를 받은 후에만 특정 문자를 인코딩할 수 있는 UTF8 및 UTF7에 영향을 줍니다.