Esempio n. 1
0
        private void StopThreads()
        {
            if (_threads.ContainsKey("Archiver"))
            {
                _archiver.RequestStop();
            }

            if (_threads.ContainsKey("Purger"))
            {
                _purger.RequestStop();
            }

            if (_threads.ContainsKey("Scheduler"))
            {
                _scheduler.RequestStop();

                // give some time to process all outstanding messages
                Thread.Sleep(250);
            }

            if (_threads.ContainsKey("Analyzer"))
            {
                _analyzer.RequestStop();

                Thread.Sleep(250);
            }

            if (_threads.ContainsKey("Writer"))
            {
                _writer.RequestStop();
            }

            // Use the Join method to block the current thread
            // until the object's thread terminates.
            if (_threads.ContainsKey("Archiver"))
            {
                _threads["Archiver"].Join();
            }

            if (_threads.ContainsKey("Purger"))
            {
                _threads["Purger"].Join();
            }

            if (_threads.ContainsKey("Scheduler"))
            {
                _threads["Scheduler"].Join();
            }

            if (_threads.ContainsKey("Analyzer"))
            {
                _threads["Analyzer"].Join();
            }

            if (_threads.ContainsKey("Writer"))
            {
                _threads["Writer"].Join();
            }
        }