Inheritance: IDisposable
Beispiel #1
0
        protected override void OnStart(string[] args)
        {
            logger.Info("Starting service...");

            try
            {
                var configuration = new ConfigurationManager(HostMetadata.MetricApp, Environment.SpecialFolder.CommonApplicationData);
                var settings = configuration.GetSection<MetricSettings>(MetricSettings.SectionKey);

                metric = new MetricInstance(settings);
                metric.Start();

                logger.Info("Service started");
            }
            catch (Exception e)
            {
                logger.Error(e);
                throw;
            }
        }
Beispiel #2
0
        private void Stop()
        {
            if (metric == null)
            {
                return;
            }

            metric.Stop();
            metric = null;

            startButton.Enabled = true;
            stopButton.Enabled = false;

            started = false;
        }
Beispiel #3
0
        private void Start()
        {
            try
            {
                startButton.Enabled = false;

                Stop();

                editDatabaseSettingsControl.Save();
                metric = new MetricInstance(settings);
                metric.Start();

                startButton.Enabled = false;
                stopButton.Enabled = true;
                started = true;
            }
            catch (Exception e)
            {
                startButton.Enabled = true;
                UIHelper.Error(e);
            }
        }