public MemoryService(IOptions <AppConfig> config, IMemoryConfigValidator memoryConfigValidator, IMessageConverter messageConverter, IMemoryInfo memoryInfo, IMessageQueueService messageQueue, ILogger <MemoryService> logger) { this.config = config; this.memoryConfigValidator = memoryConfigValidator; this.messageConverter = messageConverter; this.memoryInfo = memoryInfo; this.messageQueue = messageQueue; this.logger = logger; }
public MainWindow() { InitializeComponent(); if (loger == null) { loger = new Loger("MainWindow"); } try { buffer = ArrayList.Synchronized(new ArrayList(new Byte[0])); cpuinfo = new GetCPUInfo(); cpuinfo.PropertyChanged += new System.ComponentModel.PropertyChangedEventHandler(PropertyChanged); memory = new MemoryInfo(); com = new SerialPort(); com.DataReceived += new System.IO.Ports.SerialDataReceivedEventHandler(com_DataReceived); connectBtn.DataContext = com; hardwareStat.DataContext = com; cupGroup.DataContext = cpuinfo; memoryGroup.DataContext = memory; hardWareGroup.DataContext = Settings.Default; ComportBox.ItemsSource = SerialPort.GetAvailables(); RateBox.ItemsSource = SerialPort.GetBaudRates(); comLostFocus(this, null); Binding b = new Binding("IsConnected"); b.Source = com; b.Converter = this.FindResource("BooleanNotConverter1") as BooleanNotConverter; b.Mode = BindingMode.OneWay; ComportBox.SetBinding(UIElement.IsEnabledProperty, b); UseDefaultRate.SetBinding(UIElement.IsEnabledProperty, b); } catch (Exception ex) { try { loger.ErrorMSG(ex); MessageBoxResult r = MessageBox.Show( String.Format(R.ErrorMsg_Format, RE.ProcessNotFind, R.StopApplication), R.Error, MessageBoxButton.YesNo, MessageBoxImage.Stop); switch (r) { case MessageBoxResult.Yes: this.Close(); break; default: break; } } catch (Exception ex2) { loger.ErrorMSG(ex2); } } }
static SystemInfo() { switch (Platform) { case Platform.Windows: MemoryInfo = new MemoryInfoWindows(); CpuInfo = new CpuInfoWindows(); break; case Platform.Linux: MemoryInfo = new MemoryInfoLinux(); CpuInfo = new CpuInfoLinux(); break; default: throw new PlatformNotSupportedException("SystemInfo"); } }
public static int GetMemoryLoad(this IMemoryInfo i) { MemoryStatusEx mse = new MemoryStatusEx(); mse.dwLength = (uint)Marshal.SizeOf(mse); if (GlobalMemoryStatusEx(ref mse)) { return((int)mse.dwMemoryLoad); } MemoryStatus ms = new MemoryStatus(); if (GlobalMemoryStatus(ref ms)) { return((int)ms.dwMemoryLoad); } return(-1); }
public static bool GetMemoryStatusEx(this IMemoryInfo m, ref MemoryStatusEx mse) { mse.dwLength = (uint)Marshal.SizeOf(mse); return(GlobalMemoryStatusEx(ref mse)); }
public static bool GetMemoryStatus(this IMemoryInfo m, ref MemoryStatus ms) { return(GlobalMemoryStatus(ref ms)); }