Centreon_EventLog_2_Syslog.Program.Start C# (CSharp) Méthode

Start() public méthode

Start process: 1 - Control if process already exist and quit if exist 2 - Loop while process not receive order to stop it 3 - Load configuration 4 - Launch thread to parse event log 5 - Wait x seconds berore goto 3
public Start ( ) : void
Résultat void
        public void Start()
        {
            if (ProcessAlreadyExist() == true)
            {
                System.Environment.Exit(-1);
            }

            lastExecTime = DateTime.Now.AddMinutes(-120);
            maxExecTime = DateTime.Now;

            do
            {
                iFilters = new Hashtable();
                eFilters = new Hashtable();

                LoadConfiguration();
                StartThread();
                WaitHandle.WaitAll(doneEvents);

                iFilters = null;
                eFilters = null;

                nextCheck = maxExecTime.AddMinutes(refreshIntervalle);

                DateTime dtNow = DateTime.Now;
                int now = dtNow.Hour * 3600 + dtNow.Minute * 60 + dtNow.Second;
                int sleep = ((nextCheck.Hour * 3600 + nextCheck.Minute * 60 + nextCheck.Second) - now);

                deb.Write("Main program", "Sleep for " + sleep + " seconds\n\n", DateTime.Now, 2);

                do
                {
                    Thread.Sleep(1000);
                    if (isActive == false)
                        break;
                    sleep--;
                }
                while (sleep > 0);

                lastExecTime = maxExecTime;
                maxExecTime = DateTime.Now;

            }
            while (isActive);

            deb.Write("Main program", "Program stop", DateTime.Now, 2);
            System.Environment.Exit(0);
        }