예제 #1
0
        private PerformanceCounter[] CreateMessageQueueCounter(WatchedMessageQueues myQueues)
        {
            CounterCreationDataCollection ccdc = new CounterCreationDataCollection();
            CounterCreationData           ccd;

            for (int i = 0; i < myQueues.Count; i++)
            {
                ccd             = new CounterCreationData();
                ccd.CounterName = myQueues[i].DisplayName;
                ccd.CounterHelp = "Shows the number of messages in the queue since " + myQueues[i].StartTime;
                ccd.CounterType = PerformanceCounterType.NumberOfItems32;
                ccdc.Add(ccd);
            }
            if (PerformanceCounterCategory.Exists(PERF_MON_CAT_MSQ_WATCHER))
            {
                PerformanceCounterCategory.Delete(PERF_MON_CAT_MSQ_WATCHER);
            }

            PerformanceCounterCategory.Create(PERF_MON_CAT_MSQ_WATCHER, "Shows the number of messages in the message queue", PerformanceCounterCategoryType.Unknown, ccdc);

            PerformanceCounter[] myCounters = new PerformanceCounter[myQueues.Count];
            for (int i = 0; i < myQueues.Count; i++)
            {
                myCounters[i] = new PerformanceCounter(PERF_MON_CAT_MSQ_WATCHER,
                                                       myQueues[i].DisplayName,
                                                       false);
            }

            return(myCounters);
        }
예제 #2
0
        private void StartService()
        {
            ConfigureTimer();

            string configFile = GetConfigFilename();

            m_WatchedDirs   = new WatchedDirectories(configFile);
            m_WatchedQueues = new WatchedMessageQueues(configFile);

            m_DirectoryCounters    = CreateDirectoryCounter(m_WatchedDirs);
            m_MessageQueueCounters = CreateMessageQueueCounter(m_WatchedQueues);

            RefreshDirectoryCounters();
            RefreshMessageQueueCounters();

            m_Timer.Start();
        }
예제 #3
0
        private void StopService()
        {
            m_Timer.Stop();

            for (int i = 0; i < m_MessageQueueCounters.Length; i++)
            {
                m_MessageQueueCounters[i].Close();
                m_MessageQueueCounters[i].Dispose();
                m_MessageQueueCounters[i] = null;
            }
            PerformanceCounterCategory.Delete(PERF_MON_CAT_MSQ_WATCHER);
            m_WatchedQueues.Dispose();
            m_WatchedQueues = null;

            for (int i = 0; i < m_DirectoryCounters.Length; i++)
            {
                m_DirectoryCounters[i].Close();
                m_DirectoryCounters[i].Dispose();
                m_DirectoryCounters[i] = null;
            }
            PerformanceCounterCategory.Delete(PERF_MON_CAT_DIR_WATCHER);
            m_WatchedDirs.Dispose();
            m_WatchedDirs = null;
        }