Ejemplo n.º 1
0
 private async Task OnPatchOnMainThread(ProtocolJsonPatchPayload payload)
 {
     if (SynchronizationContext.Current == null)
     {
         // we are on working thread
         _coreData.RunOnMainThread(() => { _ = OnPatch(payload); });
     }
     else
     {
         await OnPatch(payload);
     }
 }
 public void Dispose()
 {
     _coreData.RunOnMainThread(() =>
     {
         var appSettings = _coreData.ThisDevice?.DeviceSettings;
         if (appSettings != null)
         {
             appSettings.CompactWnd     = _compactRect;
             appSettings.NormalWnd      = _normalRect;
             appSettings.AppWindowState = _lastState;
         }
     });
 }
Ejemplo n.º 3
0
        private async Task StartCpuProcessing()
        {
            await TaskHelper.GoToPool().ConfigureAwait(false);

            while (!_cts.IsCancellationRequested)
            {
                try
                {
                    int load = (int)_cpu.NextValue();
                    load = _loadAverage.AddValue(load);
#if DEBUG
                    ProcessLoad[] processes = null;
#else
                    var processes = GetProcesses();
#endif
                    _coreData.RunOnMainThread(() => SetLoad(load, processes));
                }
                catch (Exception e)
                {
                    Log.Warning(e, $"Get CPU load failed");
                }
                await Task.Delay(1000, _cts.Token);
            }
        }