Partage via


WebEventProvider.Flush Méthode

Définition

Déplace les événements de la mémoire tampon du fournisseur vers le journal des événements.

public:
 abstract void Flush();
public abstract void Flush ();
abstract member Flush : unit -> unit
Public MustOverride Sub Flush ()

Exemples

L'exemple de code suivant montre comment utiliser la méthode 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

Remarques

Lorsque cette méthode est appelée, tous les événements de la mémoire tampon sont immédiatement déplacés de la mémoire tampon vers le journal des événements, quel que soit le temps écoulé depuis la dernière écriture ou le nombre d’événements présents dans la mémoire tampon. L’heure de la dernière écriture est réinitialisée à l’heure de l’action de vidage.

S’applique à