private async void ProgressIndicatorUpdate() { partLoadInfo = new PartLoadInfo(); partLoadInfo.UpdateContext(); double cpuUsage = await partLoadInfo.AverageCpuUsage(); Xamarin.Essentials.MainThread.BeginInvokeOnMainThread( delegate { circularProgress.SetProgress((int)partLoadInfo.UsedRamMB, (int)partLoadInfo.TotalRamMB); circularProgressCpu.SetProgress((int)cpuUsage, 100); }); }
private void FillRamView(CancellationToken token) { try { while (true) { System.Threading.Thread.Sleep(500); Xamarin.Essentials.MainThread.BeginInvokeOnMainThread( delegate { partLoadInfo = new PartLoadInfo(); partLoadInfo.UpdateContext(); if (partLoadInfo.PercentUsed >= 75) { circularProgress.ProgressColor = Color.DarkRed; } if (partLoadInfo.PercentUsed >= 85) { //cancellationToken.Cancel(); } else { circularProgress.ProgressColor = Color.DarkGreen; } ProgressIndicatorUpdate(); }); if (token.IsCancellationRequested) { break; } } } catch (System.Exception ex) { #region Logging LogRuntimeAttribute.InLogFiles(typeof(DashboardFragment), ex); #endregion } finally { } }