//首页信息 3秒变化一次 private void FirstPageThreadStart() { while (true) { //UpDateSystemInfo(); this.Dispatcher.BeginInvoke(new Action(() => { //系统时间跟新 systemTimeNow_TextBlock.Text = "当前系统时间:" + DateTime.Now.ToString(); int tickCount = Environment.TickCount; systemUsingTime_TextBlock.Text = "电脑已经开机:" + Convert.ToString(tickCount / 3600000) + "时:" + Convert.ToString((tickCount % 3600000) / 60000) + "分:" + Convert.ToString((tickCount % 60000) / 1000) + "秒"; //网络状况 SystemInfoHelper.UpdateNetInfo(); netWorkState_TextBlock.Text = SystemInfoHelper.IsOnline == true ? "连接网络" : "未连接网络"; IpAddress_TextBlock.Text = SystemInfoHelper.IPAddress; IpSubnet_TextBlock.Text = SystemInfoHelper.IPSubnet; //cpu SystemInfoHelper.UpdateCpuUsage(); cpuRate_TextBlock.Text = "系统cpu使用率" + SystemInfoHelper.SysCpuUsage + "%"; cpu_ProgressBar.Value = double.Parse(SystemInfoHelper.SysCpuUsage); //内存 SystemInfoHelper.UpdateMemoryUsage(); memoryRate_TextBlock.Text = "系统内存使用率" + SystemInfoHelper.SysMemoryUsage + "%"; memory_ProgressBar.Value = double.Parse(SystemInfoHelper.SysMemoryUsage); }), null); Thread.Sleep(3000); } }
private void UpDateSystemInfo() { //进程个数 processesNums_Now.Text = SystemInfoHelper.GetProcessesNum().ToString(); //cpu占用率 cpu_Rate.Text = SystemInfoHelper.SysCpuUsage + "%"; //内存占用率 memory_Rate.Text = SystemInfoHelper.SysMemoryUsage + "%"; //Gpu温度 gpu_temperature.Text = SystemInfoHelper.GetGPUTemperature().ToString() + "°C"; }