Пример #1
0
        private void OnShowHddLoadsCallback(object state)
        {
            if (string.IsNullOrEmpty(this.currentSelectedHdd))
            {
                return;
            }

            var  hddLoad = string.Empty;
            bool allHdds = false;

            allHdds = this.currentSelectedHdd == WsapmTools.GetCommonDiaplayNameAllDrives();

            try
            {
                if (allHdds)
                {
                    hddLoad = WsapmConvert.ConvertByteToKB(this.hddLoad.GetCurrentHddLoadTotalAllHdds()).ToString("0.00") + " KB/s";
                }
                else
                {
                    hddLoad = WsapmConvert.ConvertByteToKB(this.hddLoad.GetCurrentHddLoadInBytesPerSecond(this.currentSelectedHdd)).ToString("0.00") + " KB/s";
                }
            }
            catch (Exception)
            {
            }

            Dispatcher.Invoke((Action)(() =>
            {
                this.labelCurrentHddLoad.Content = hddLoad;
            }));
        }
Пример #2
0
        void timer_Tick(object sender, EventArgs e)
        {
            try
            {
                switch (this.checkType)
                {
                case LoadCheckType.Cpu:
                    this.textBlockLoad.Text += this.cpuLoad.GetAverageCpuLoad(numberOfProbes, breakBetweenProbes).ToString("0.00") + " %" + Environment.NewLine;
                    break;

                case LoadCheckType.NetworkTotal:
                    this.textBlockLoad.Text += (WsapmConvert.ConvertByteToKB(this.networkLoad.GetAverageNetworkLoadTotalInBytesPerSecond(numberOfProbes, breakBetweenProbes))).ToString("0.00") + " KB/s" + Environment.NewLine;
                    break;

                case LoadCheckType.NetworkReceived:
                    this.textBlockLoad.Text += (WsapmConvert.ConvertByteToKB(this.networkLoad.GetCurrentNetworkLoadReceivedInBytesPerSecond(numberOfProbes, breakBetweenProbes))).ToString("0.00") + " KB/s" + Environment.NewLine;
                    break;

                case LoadCheckType.NetworkSent:
                    this.textBlockLoad.Text += (WsapmConvert.ConvertByteToKB(this.networkLoad.GetCurrentNetworkLoadSentInBytesPerSecond(numberOfProbes, breakBetweenProbes))).ToString("0.00") + " KB/s" + Environment.NewLine;
                    break;

                default:
                    break;
                }
            }
            catch (Exception ex)
            {
                if (this.timer != null)
                {
                    this.timer.Stop();
                    this.timer.Tick -= timer_Tick;
                }

                MessageBox.Show(String.Format(Wsapm.Resources.Wsapm.LoadWindow_ReadValueError, Environment.NewLine, ex.Message), Wsapm.Resources.Wsapm.General_MessageBoxErrorTitle, MessageBoxButton.OK, MessageBoxImage.Error);
                this.Dispatcher.Invoke((Action)(() => this.Close()));
            }

            this.scrollViewer.ScrollToEnd();
            CommandManager.InvalidateRequerySuggested();
        }