StreamWriter.AutoFlush 속성

정의

호출할 때마다 StreamWriter해당 버퍼를 기본 스트림으로 플러시할지 여부를 Write(Char) 나타내는 값을 가져오거나 설정합니다.

public:
 virtual property bool AutoFlush { bool get(); void set(bool value); };
public virtual bool AutoFlush { get; set; }
member this.AutoFlush : bool with get, set
Public Overridable Property AutoFlush As Boolean

속성 값

true 버퍼를 강제로 StreamWriter 플러시하려면 .이고, false그렇지 않으면 .입니다.

예제

다음 예제에서는 속성을 사용 하는 구문을 보여 있습니다 AutoFlush .

// Gets or sets a value indicating whether the StreamWriter
// will flush its buffer to the underlying stream after every
// call to StreamWriter.Write.
sw.AutoFlush = true;
' Gets or sets a value indicating whether the StreamWriter
' will flush its buffer to the underlying stream after every 
' call to StreamWriter.Write.
Sw.AutoFlush = True

설명

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

AutoFlushfalse 설정하면 StreamWriter 전달한 인코딩의 인코더에서 내부적으로나 잠재적으로 제한된 양의 버퍼링이 수행됩니다. 쓰기AutoFlushfalse마쳤을 때 항상 호출 Close (또는 적어도Flush)으로 설정 StreamWriter 하여 성능을 높일 수 있습니다.

예를 들어 사용자가 즉각적인 피드백을 기대하는 디바이스에 쓸 때로 설정합니다 AutoFlushtrue . Console.Out 는 다음과 같은 StreamWriter 경우 중 하나입니다. 내부적으로 쓰기에 사용되어 Console 호출할 때마다 인코더 상태를 제외한 모든 내부 상태를 플러시합니다 StreamWriter.Write.

일반적인 I/O 작업 목록은 일반적인 I/O 작업을 참조하세요.

적용 대상

추가 정보