コード例 #1
0
        protected override bool Run(object parameters)
        {
            if (StaticServerDetails == null)
            {
                StaticServerDetails = new StaticServerDetails(true);
            }

            try
            {
                if (!_initialised)
                {
                    InitialiseAllCounters();
                    _initialised = true;
                }

                DynamicServerDetails dynamicServerDetails = new DynamicServerDetails(true,
                                                                                     _cpuPerformanceCounter,
                                                                                     _memoryPerformanceCounter,
                                                                                     MonitorDisks ? _diskPerformanceCounter : null,
                                                                                     MonitorNetwork ? _netorkPerformanceCounter : null,
                                                                                     MonitorNetworkAdapters ? _networkAdapterCounter : null);

                using (Shared.Classes.TimedLock.Lock(_lockObject))
                {
                    if (DynamicServerDetails.Count == 100)
                    {
                        DynamicServerDetails.Dequeue();
                    }

                    DynamicServerDetails.Enqueue(dynamicServerDetails);
                }

                if (OnNewServerDetails != null)
                {
                    OnNewServerDetails(this, new DynamicServerDetailsEventArgs(dynamicServerDetails));
                }

                System.Threading.Thread.Sleep(0);
            }
            catch (Exception error)
            {
                Shared.EventLog.Add(error);
            }

            return(!HasCancelled());
        }
コード例 #2
0
 public DynamicServerDetailsEventArgs(DynamicServerDetails dynamicDetails)
 {
     Details = dynamicDetails;
 }