static async Task RunControlEndpoint(IPEndPoint controlEP) { var config = new HttpSelfHostConfiguration( new UriBuilder(Uri.UriSchemeHttp, "localhost", controlEP.Port).Uri); config.Routes.MapHttpRoute("API", "{controller}/{id}", new { id = RouteParameter.Optional }); var controlServer = new HttpSelfHostServer(config); try { await controlServer.OpenAsync(); Trace.TraceInformation("Control endpoint listening at {0}", config.BaseAddress); } catch (Exception exception) { controlServer.Dispose(); Trace.TraceError("Control endpoint cannot open, {0}", exception.Message); throw; } await ClosingEvent.Task; try { await controlServer.CloseAsync(); } finally { controlServer.Dispose(); } }
public void Stop() { server.CloseAsync(); server.Dispose(); Console.WriteLine("Server stop!" + baseAddress); WorkingBD.SaveLog("Сервер остановлен"); }
public void Dispose() { if (_server != null) { _server.Dispose(); } }
public void Stop() { LoginMonitor.Quit(); server.CloseAsync(); server.Dispose(); }
public async Task Stop() { await _server.CloseAsync(); _server.Dispose(); PhotoCatcher.Instance.Dispose(); }
/// <summary> /// /// </summary> /// <param name="e"></param> protected override void OnExit(ExitEventArgs e) { _server.CloseAsync().Wait(); _server.Dispose(); base.OnExit(e); }
protected override void OnStop() { if (server != null) { server.CloseAsync().Wait(); server.Dispose(); } }
/// <summary> /// stop queue listener /// </summary> public void Stop() { if (_httpSelfHostServer != null) { _httpSelfHostServer.CloseAsync(); _httpSelfHostServer.Dispose(); } }
public void Teardown() { _webServer.CloseAsync().Wait(); _webServer.Dispose(); Container.Dispose(); ContainerBuilder = null; Container = null; }
private void StopWebAPI() { Log.ConsoleAndFile("Stopping web API..."); m_apiServer.CloseAsync().Wait(); m_apiServer.Dispose(); m_apiServer = null; Log.ConsoleAndFile("Web API stopped successfully"); }
public void Dispose() { if (_server != null) { _server.CloseAsync().Wait(); _server.Dispose(); _server = null; } }
/// <summary> /// 关闭WebApi监听 /// </summary> public static void Stop() { if (server != null) { server.CloseAsync().Wait(); server.Dispose(); Console.WriteLine("关闭Http监听"); } }
public void Dispose() { if (Server != null) { Server.CloseAsync().Wait(); Server.Dispose(); Server = null; } }
public ValueTask DisposeAsync() { return(_server == default ? default : closeServer()); async ValueTask closeServer() { try { await _server.CloseAsync(); _server.Dispose(); } catch { /*discarded */ } } }
public void Stop() { if (selfHostingServer != null) { selfHostingServer.CloseAsync(); selfHostingServer.Dispose(); selfHostingServer = null; } }
public bool Stop(HostControl control) { _logger.Debug("Stopping Service..."); _scheduler.Stop(); server.CloseAsync(); server.Dispose(); return(true); }
public void Stop() { Log.Info("Stopping"); Server.CloseAsync().Wait(); Server.Dispose(); lock (Locker) current = null; Log.Info("Stopped"); }
protected void Dispose(bool disposing) { Server.Dispose(); if (disposing) { GC.SuppressFinalize(this); } }
public void Stop() { timeoutTimer?.Stop(); if (serviceHost != null) { serviceHost.CloseAsync().Wait(); serviceHost.Dispose(); } }
public static async Task StopAsync() { if (_server != null) { await _server.CloseAsync(); _server.Dispose(); } }
protected override void OnStop() { //s_TcpFileServer.Stop(); if (_server != null) { _server.CloseAsync().Wait(); _server.Dispose(); } }
public void Stop() { _bus.Dispose(); _bus = null; _server.CloseAsync().Wait(); _server.Dispose(); _scheduler.Shutdown(false); }
public void Stop() { if (_server == null) { return; } _server.CloseAsync().Wait(); _server.Dispose(); _server = null; }
public bool Stop(HostControl hostControl) { _log.Info("SampleService Stopped"); FileManager.MemoryCatch(); if (_throwOnStop) { throw new InvalidOperationException("Throw on Stop Requested!"); } _server.CloseAsync().Wait(); _server.Dispose(); return(true); }
public void Clean() { if (_webApp != null) { #if NET40 _webApp.CloseAsync().Wait(); #endif _webApp.Dispose(); _webApp = null; } Current = null; }
/// <summary> /// WebApi服务关闭 /// </summary> /// <returns></returns> public static async Task ServerCloseAsync() { if (!_is_serverStarted) { return; } await _webapi_server.CloseAsync(); _is_serverStarted = !_is_serverStarted; _webapi_server.Dispose(); }
public static void Stopp() { if (_client != null) { _client.Dispose(); _client = null; } if (_server != null) { _server.CloseAsync().Wait(); _server.Dispose(); _server = null; } }
public static void AssemblyCleanup() { server.CloseAsync().Wait(); if (server != null) { server.Dispose(); } if (client != null) { client.Dispose(); } Database.Delete(testDatabaseConnection); }
internal static void RunServer(string endpoint) { Task.Run( async() => { while (true) { var config = new HttpSelfHostConfiguration(endpoint); config.Routes.MapHttpRoute( "API Default", "api/{controller}/{action}"); var server = new HttpSelfHostServer(config); await server.OpenAsync(); await Task.Delay(TimeSpan.MaxValue); server.Dispose(); } }); }
public void ValueController_WithGetMethos_ShouldReturnValidData_NoBaseClass() { HttpSelfHostConfiguration configuration = new HttpSelfHostConfiguration("http://localhost:8080"); configuration.IncludeErrorDetailPolicy = IncludeErrorDetailPolicy.Always; configuration.Services.Replace(typeof(IAssembliesResolver), new WebApiClassBase.TestAssemblyResolver(typeof(ValuesController))); configuration.Routes.MapHttpRoute("Default", "{controller}", new { controller = "Home" }); HttpSelfHostServer server = new HttpSelfHostServer(configuration); try { server.OpenAsync().Wait(); var request = new HttpRequestMessage(); request.RequestUri = new Uri("http://localhost:8080"); request.Method = HttpMethod.Get; var client = new HttpClient(server); using (HttpResponseMessage response = client.SendAsync(request).Result) { response.Should().Not.Be.Null(); response.IsSuccessStatusCode.Should().Be.True(); string[] result = response.Content.ReadAsAsync <string[]>().Result; result.Length.Should().Be.EqualTo(4); result[0].Should().Be.EqualTo("http://tostring.it"); result[1].Should().Be.EqualTo("http://imperugo.tostring.it"); result[2].Should().Be.EqualTo("http://twitter.com/imperugo"); result[3].Should().Be.EqualTo("http://www.linkedin.com/in/imperugo"); } } finally { configuration.Dispose(); server.Dispose(); } }