HttpListener.IsListening 속성

정의

HttpListener가 시작되었는지 여부를 나타내는 값을 가져옵니다.

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

속성 값

Boolean

HttpListener가 시작되었으면 true이고, 그렇지 않으면 false입니다.

예제

다음 코드 예제에서는 인스턴스의 수신 대기 상태를 확인 하려면이 속성을 사용 하 여 보여 줍니다.

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

설명

시작 HttpListener하려면 메서드를 호출합니다 Start .

적용 대상