Exemplo n.º 1
0
        public void Start()
        {
            // Create the management service
            this.serviceHost = new ServiceHost(
                typeof(ManagementService),
                new Uri("net.pipe://localhost"));

            this.serviceHost.AddServiceEndpoint(
                typeof(IManagementService),
                new NetNamedPipeBinding(),
                "Wingnut");

            ServiceDebugBehavior behavior =
                this.serviceHost.Description.Behaviors.Find <ServiceDebugBehavior>();

            if (behavior == null)
            {
                behavior = new ServiceDebugBehavior();
                this.serviceHost.Description.Behaviors.Add(behavior);
            }

            behavior.IncludeExceptionDetailInFaults = true;

            Logger.Debug("ServiceRuntime: Opening WCF service host");

            this.serviceHost.Open();

            upsMonitor = new UpsMonitor();

            Logger.Debug("ServiceRuntime: Starting UPSMonitor");

            upsMonitor.Start();
        }
Exemplo n.º 2
0
        public void StartMonitoring(
            UpsMonitor monitor,
            CancellationToken monitoringCancellationToken)
        {
            this.upsMonitor = monitor;

            this.cancellationTokenSource =
                CancellationTokenSource.CreateLinkedTokenSource(
                    monitoringCancellationToken);

            this.MonitoringTask = Task.Run(
                async() => await this.MonitorUpsMain().ConfigureAwait(false),
                this.cancellationTokenSource.Token);
        }