public void PoolerMain(object systemInfo) { _systemInfo = (SystemInfo)systemInfo; _wmiGetter = new WmiGetter(); _systemInfo.MemTot = _wmiGetter.GetTotMem(); while (true) { _systemInfo.CpuLoad = _wmiGetter.GetCpuLoad(); _systemInfo.MemFree = _wmiGetter.GetAvailableMem(); Thread.Sleep(500); } }
bool StartPooler() { try { if (_pooler == null) _pooler = new RessourcePooler(); if (SystemInfo == null) SystemInfo = new SystemInfo(); if (_poolerThread == null) _poolerThread = new Thread(new ParameterizedThreadStart(_pooler.PoolerMain)); _poolerThread.Start(SystemInfo); while (!_poolerThread.IsAlive) ; IsPoolerStarted = true; return true; } catch (Exception e) { MessageBox.Show(e.Message); return false; } }