HttpListener.IsListening HttpListener.IsListening HttpListener.IsListening HttpListener.IsListening Property

Définition

Obtient une valeur qui indique si HttpListener a été démarré.Gets a value that indicates whether HttpListener has been started.

public:
 property bool IsListening { bool get(); };
public bool IsListening { get; }
member this.IsListening : bool
Public ReadOnly Property IsListening As Boolean

Valeur de propriété

true si HttpListener a été démarré ; sinon, false.true if the HttpListener was started; otherwise, false.

Exemples

L’exemple de code suivant illustre l’utilisation de cette propriété pour déterminer l’état d’écoute d’une instance.The following code example demonstrates using this property to determine the listening state of an instance.

public static void DisplayPrefixesAndState(HttpListener listener)
{
    // List the prefixes to which the server listens.
    HttpListenerPrefixCollection prefixes = listener.Prefixes;
    if (prefixes.Count == 0)
    {
        Console.WriteLine("There are no prefixes.");
    }
    foreach(string prefix in prefixes)
    {
        Console.WriteLine(prefix);
    }
    // Show the listening state.
    if (listener.IsListening)
    {
        Console.WriteLine("The server is listening.");
    }
}
Public Shared Sub DisplayPrefixesAndState(ByVal listener As HttpListener)
    ' List the prefixes to which the server listens.
    Dim prefixes As HttpListenerPrefixCollection = listener.Prefixes

    If prefixes.Count = 0 Then
        Console.WriteLine("There are no prefixes.")
    End If

    For Each prefix As String In prefixes
        Console.WriteLine(prefix)
    Next

    ' Show the listening state.
    If listener.IsListening Then
        Console.WriteLine("The server is listening.")
    End If
End Sub

Remarques

Pour démarrer un HttpListener, appelez le Start (méthode).To start an HttpListener, call the Start method.

S’applique à