StreamWriter.AutoFlush 속성

정의

StreamWriterWrite(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

속성 값

StreamWriter가 해당 버퍼를 플러시하게 하려면 true이고, 그렇지 않으면 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;
' 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

설명

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

가 로 falseStreamWriter 설정되면 AutoFlush 전달한 인코딩의 인코더에서 내부적으로나 잠재적으로 제한된 양의 버퍼링을 수행합니다. 를 사용하여 쓰기StreamWriter를 마쳤을 false때 항상 (또는 적어도 Flush)을 호출 Close 한다고 가정하면 를 로 설정 AutoFlush 하여 성능을 향상할 수 있습니다.

예를 들어, 설정 AutoFlushtrue 사용자 대 한 즉각적인 피드백을 기대 하는 디바이스에 작성 하는 경우. Console.Out는 이러한 경우 StreamWriter 중 하나입니다. 에 대한 호출 StreamWriter.Write후 인코더 상태를 제외한 모든 내부 상태를 플러시하기 위해 Console 내부적으로 사용되는 입니다.

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

적용 대상

추가 정보