/// <summary> /// Stops the mock server. /// </summary> public void Stop() { try { Listener.Abort(); var task = _listenerTask; _listenerTask = null; if (task != null) { task.Wait(); } } catch (Exception ex) { Debug.Fail(ex.ToString()); } }
/// <summary> /// プロパティ(<see cref="Listener"/>)の <see cref="HttpListener"/> オブジェクトを強制終了する /// </summary> private void HttpListenerAbort() { // ローカルHTTPサーバが起動しているかどうかのフラグをOFFにする // (エラー処理で呼び出された時のためフラグ設定処理) IsRunning = false; // サーバが停止するためURLをNULLにする Url = null; // HttpListenerを強制終了する try { // サーバ自体を止めるため要求キューを処理せずに終了する Listener?.Abort(); } finally { // HttpListenerを初期化する Listener = null; } }