Ejemplo n.º 1
0
        protected override void OnStart(string[] args)
        {
            lock (m_Sync)
            {
                m_Configuration = TFTPServerConfigurationList.Read(Program.GetConfigurationPath());
                m_Servers       = new List <TFTPServerResurrector>();

                foreach (var config in m_Configuration)
                {
                    m_Servers.Add(new TFTPServerResurrector(config, m_EventLog));
                }
            }
            Instance = this;

            m_SelfHost = new ServiceHost(typeof(TFTPServiceContractImpl));

            try
            {
                NetNamedPipeBinding binding = new NetNamedPipeBinding(NetNamedPipeSecurityMode.None);
                m_SelfHost.AddServiceEndpoint(typeof(ITFTPServiceContract), binding, "net.pipe://localhost/JPMikkers/TFTPServer/Service");
                m_SelfHost.Open();
            }
            catch (CommunicationException)
            {
                m_SelfHost.Abort();
            }
        }
Ejemplo n.º 2
0
        protected override void OnStop()
        {
            try
            {
                // Close the ServiceHostBase to shutdown the service.
                m_SelfHost.Close();
            }
            catch (CommunicationException)
            {
                m_SelfHost.Abort();
            }

            Instance = null;

            lock (m_Sync)
            {
                foreach (var server in m_Servers)
                {
                    server.Dispose();
                }
                m_Servers.Clear();
            }
        }