Exemple #1
0
        protected override void OnStart(string[] args)
        {
            base.OnStart(args);
            loggingSvc.Write($"Service Started -> {_serviceName}");
            string status = "No";

            if (!_bypassAuth)
            {
                authToken     = WebOperations.AuthenticateAgent(AgentName: _serviceName, ServerName: srvName); // Agent authentication
                status        = authToken.Length > 0 ? "Yes" : "No";
                _mainSvcTimer = new Timer(callback: ActionMain, state: null, dueTime: TimeSpan.Zero, period: TimeSpan.FromMinutes(60));
            }
            else
            {
                _mainSvcTimer = new Timer(callback: ActionMain, state: null, dueTime: 0, period: 1);
                Thread.Sleep(1);
                _mainSvcTimer?.Change(dueTime: Timeout.Infinite, period: 0);
            }

            loggingSvc.Write($"Agent Authentication Required -> {status}");
        }