Exemple #1
0
        protected override void OnStart(string[] args)
        {
            var version_strings = Assembly.GetExecutingAssembly().GetName().Version.ToString().Split('.');
            var version_string  = "DeviceServer v" + version_strings[0] + "." + version_strings[1] + " Prerelease " + version_strings[2] + "." + version_strings[3];

            logger.AppendLog(DateTime.Now, version_string);
            logger.AppendLog(DateTime.Now, "Service - Starting");

            DeviceConnectionManager.Start();
            ServerAdvertiser.Start();
            ServerListener.Start();

            logger.AppendLog(DateTime.Now, "Service - Started");
        }
Exemple #2
0
        public DeviceServer()
        {
            InitializeComponent();

            var version_strings = Assembly.GetExecutingAssembly().GetName().Version.ToString().Split('.');
            var version_string  = "DeviceServer v" + version_strings[0] + "." + version_strings[1] + " Prerelease " + version_strings[2] + "." + version_strings[3];

            logger.AppendLog(DateTime.Now, version_string);
            logger.AppendLog(DateTime.Now, "Service - Starting");

            DeviceConnectionManager.Start();
            ServerAdvertiser.Start();
            ServerListener.Start();

            logger.AppendLog(DateTime.Now, "Service - Started");
        }
Exemple #3
0
        protected override void OnStop()
        {
            Task.Run(() =>
            {
                var version_strings = Assembly.GetExecutingAssembly().GetName().Version.ToString().Split('.');
                var version_string  = "DeviceServer v" + version_strings[0] + "." + version_strings[1] + " Prerelease " + version_strings[2] + "." + version_strings[3];

                logger.AppendLog(DateTime.Now, version_string);
                logger.AppendLog(DateTime.Now, "Service - Stopping");

                var handle = ServerListener.Stop();
                handle.WaitOne();

                handle = ServerAdvertiser.Stop();
                handle.WaitOne();

                handle = DeviceConnectionManager.Stop();
                handle.WaitOne();

                logger.AppendLog(DateTime.Now, "Service - Stopped");
            });
        }