Ejemplo n.º 1
0
        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();
            }
        }
Ejemplo n.º 2
0
 public void Stop()
 {
     server.CloseAsync();
     server.Dispose();
     Console.WriteLine("Server stop!" + baseAddress);
     WorkingBD.SaveLog("Сервер остановлен");
 }
Ejemplo n.º 3
0
 public void Dispose()
 {
     if (_server != null)
     {
         _server.Dispose();
     }
 }
Ejemplo n.º 4
0
        public void Stop()
        {
            LoginMonitor.Quit();

            server.CloseAsync();
            server.Dispose();
        }
Ejemplo n.º 5
0
        public async Task Stop()
        {
            await _server.CloseAsync();

            _server.Dispose();
            PhotoCatcher.Instance.Dispose();
        }
Ejemplo n.º 6
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="e"></param>
        protected override void OnExit(ExitEventArgs e)
        {
            _server.CloseAsync().Wait();
            _server.Dispose();

            base.OnExit(e);
        }
Ejemplo n.º 7
0
 protected override void OnStop()
 {
     if (server != null)
     {
         server.CloseAsync().Wait();
         server.Dispose();
     }
 }
Ejemplo n.º 8
0
 /// <summary>
 /// stop queue listener
 /// </summary>
 public void Stop()
 {
     if (_httpSelfHostServer != null)
     {
         _httpSelfHostServer.CloseAsync();
         _httpSelfHostServer.Dispose();
     }
 }
Ejemplo n.º 9
0
 public void Teardown()
 {
     _webServer.CloseAsync().Wait();
     _webServer.Dispose();
     Container.Dispose();
     ContainerBuilder = null;
     Container        = null;
 }
Ejemplo n.º 10
0
 private void StopWebAPI()
 {
     Log.ConsoleAndFile("Stopping web API...");
     m_apiServer.CloseAsync().Wait();
     m_apiServer.Dispose();
     m_apiServer = null;
     Log.ConsoleAndFile("Web API stopped successfully");
 }
Ejemplo n.º 11
0
 public void Dispose()
 {
     if (_server != null)
     {
         _server.CloseAsync().Wait();
         _server.Dispose();
         _server = null;
     }
 }
Ejemplo n.º 12
0
 /// <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 */ }
            }
        }
Ejemplo n.º 15
0
 public void Stop()
 {
     if (selfHostingServer != null)
     {
         selfHostingServer.CloseAsync();
         selfHostingServer.Dispose();
         selfHostingServer = null;
     }
 }
Ejemplo n.º 16
0
        public bool Stop(HostControl control)
        {
            _logger.Debug("Stopping Service...");
            _scheduler.Stop();
            server.CloseAsync();
            server.Dispose();

            return(true);
        }
Ejemplo n.º 17
0
 public void Stop()
 {
     Log.Info("Stopping");
     Server.CloseAsync().Wait();
     Server.Dispose();
     lock (Locker)
         current = null;
     Log.Info("Stopped");
 }
Ejemplo n.º 18
0
        protected void Dispose(bool disposing)
        {
            Server.Dispose();

            if (disposing)
            {
                GC.SuppressFinalize(this);
            }
        }
Ejemplo n.º 19
0
 public void Stop()
 {
     timeoutTimer?.Stop();
     if (serviceHost != null)
     {
         serviceHost.CloseAsync().Wait();
         serviceHost.Dispose();
     }
 }
Ejemplo n.º 20
0
        public static async Task StopAsync()
        {
            if (_server != null)
            {
                await _server.CloseAsync();

                _server.Dispose();
            }
        }
Ejemplo n.º 21
0
        protected override void OnStop()
        {
            //s_TcpFileServer.Stop();

            if (_server != null)
            {
                _server.CloseAsync().Wait();
                _server.Dispose();
            }
        }
Ejemplo n.º 22
0
        public void Stop()
        {
            _bus.Dispose();
            _bus = null;

            _server.CloseAsync().Wait();
            _server.Dispose();

            _scheduler.Shutdown(false);
        }
Ejemplo n.º 23
0
        public void Stop()
        {
            if (_server == null)
            {
                return;
            }

            _server.CloseAsync().Wait();
            _server.Dispose();
            _server = null;
        }
Ejemplo n.º 24
0
 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);
 }
Ejemplo n.º 25
0
        public void Clean()
        {
            if (_webApp != null)
            {
#if NET40
                _webApp.CloseAsync().Wait();
#endif
                _webApp.Dispose();
                _webApp = null;
            }
            Current = null;
        }
Ejemplo n.º 26
0
        /// <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();
        }
Ejemplo n.º 27
0
        public static void Stopp()
        {
            if (_client != null)
            {
                _client.Dispose();
                _client = null;
            }

            if (_server != null)
            {
                _server.CloseAsync().Wait();
                _server.Dispose();
                _server = null;
            }
        }
Ejemplo n.º 28
0
        public static void AssemblyCleanup()
        {
            server.CloseAsync().Wait();

            if (server != null)
            {
                server.Dispose();
            }

            if (client != null)
            {
                client.Dispose();
            }

            Database.Delete(testDatabaseConnection);
        }
Ejemplo n.º 29
0
 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();
            }
        }