/// <summary> /// Service STOP /// </summary> protected override void OnStop() { if (Config.StopAction != null) Config.StopAction.Invoke(); if (Host != null) { GC.KeepAlive(Host.SingletonInstance); GC.KeepAlive(Host); ZapTimer.Stop(); Host.Close(); Host = null; } }
/// <summary> /// Service START /// </summary> /// <param name="args">dodatkowe parametry</param> protected override void OnStart(string[] args) { if (Config.StartAction != null) { try { Config.StartAction.Invoke(); if (Host != null) Host.Close(); } catch (Exception x) { Log.Exception(x); } } Host = new WebServiceHost(Config.Type, new Uri(Config.Uri)); ZapTimer.Start(); try { Host.Open(); } catch (AddressAccessDeniedException) { throw new AddressAccessDeniedException("Insuficient privileges to open WebServiceHost."); } }