WebEventProvider.Flush 方法
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
將事件從提供者的緩衝區移至事件記錄檔。
public:
abstract void Flush();
public abstract void Flush ();
abstract member Flush : unit -> unit
Public MustOverride Sub Flush ()
範例
下列程式碼範例示範如何使用 Flush 方法。
// Flush the input buffer if required.
public override void Flush()
{
// Create a string builder to
// hold the event information.
StringBuilder reData = new StringBuilder();
// Store custom information.
reData.Append("SampleEventProvider processing." +
Environment.NewLine);
reData.Append("Flush done at: {0}" +
DateTime.Now.TimeOfDay.ToString() +
Environment.NewLine);
foreach (WebBaseEvent e in msgBuffer)
{
// Store event data.
reData.Append(e.ToString());
}
// Store the information in the specified file.
StoreToFile(reData, logFilePath, FileMode.Append);
// Reset the message counter.
msgCounter = 0;
// Clear the buffer.
msgBuffer.Clear();
}
' Flush the input buffer if required.
Public Overrides Sub Flush()
' Create a string builder to
' hold the event information.
Dim reData As New StringBuilder()
' Store custom information.
reData.Append( _
"SampleEventProvider processing." + _
Environment.NewLine)
reData.Append( _
"Flush done at: {0}" + _
DateTime.Now.TimeOfDay.ToString() + _
Environment.NewLine)
Dim e As WebBaseEvent
For Each e In msgBuffer
' Store event data.
reData.Append(e.ToString())
Next e
' Store the information in the specified file.
StoreToFile(reData, logFilePath, FileMode.Append)
' Reset the message counter.
msgCounter = 0
' Clear the buffer.
msgBuffer.Clear()
End Sub
備註
呼叫這個方法時,緩衝區中的所有事件都會立即從緩衝區移至事件記錄檔,而不論自上次寫入以來已耗用多少時間,或緩衝區中有多少事件。 上次寫入的時間會重設為排清動作的時間。