Ejemplo n.º 1
0
        /// <summary>
        /// When implemented in a derived class, executes when a Stop command is sent to the service by the Service Control Manager (SCM). Specifies actions to take when a service stops running.
        /// </summary>
        protected override void OnStop()
        {
            // log
            log.Info("Service is stopping.");

            // stop and empty the service
            if (surveillanceService != null)
            {
                surveillanceService.Stop();
                surveillanceService = null;
            }

            // log
            log.Info("Service has stopped.");
        }
Ejemplo n.º 2
0
        /// <summary>
        /// When implemented in a derived class, executes when a Start command is sent to the service by the Service Control Manager (SCM) or when the operating system starts (for a service that starts automatically). Specifies actions to take when the service starts.
        /// </summary>
        /// <param name="args">Data passed by the start command.</param>
        protected override void OnStart(string[] args)
        {
            // log
            log.Info("Service is starting.");

            // clear the old service
            if (surveillanceService != null)
            {
                surveillanceService.Stop();
            }

            // create a new service to watch from
            surveillanceService = new SurveillanceService();

            // start to watch on the configured cameras
            surveillanceService.Start();

            // log
            log.Info("Service has started and is watching on {0} cameras.", surveillanceService.NrOfCameras);

            SurveillanceWebserver webServer = new SurveillanceWebserver();

            webServer.Bind(surveillanceService.Cameras);
        }