internal async Task OnBackgroundModeChangedAsync(object sender, BackgroundModeChangedEventArgs args) { var goingIntoBackground = args.IsInBackground; var wasInBackground = LockUtils.WithWriteLock(_stateLock, () => { var oldValue = _inBackground; _inBackground = goingIntoBackground; return(oldValue); }); if (goingIntoBackground == wasInBackground) { return; } Log.DebugFormat("Background mode is changing to {0}", goingIntoBackground); if (goingIntoBackground) { if (!Config.EnableBackgroundUpdating) { Log.Debug("Background updating is disabled"); await _connectionManager.SetUpdateProcessorFactory(null, false); return; } Log.Debug("Background updating is enabled, starting polling processor"); } await _connectionManager.SetUpdateProcessorFactory( Factory.CreateUpdateProcessorFactory(_config, User, flagCacheManager, goingIntoBackground), false // don't reset initialized state because the user is still the same ); }
internal void OnBackgroundModeChanged(object sender, BackgroundModeChangedEventArgs args) { _ = OnBackgroundModeChangedAsync(sender, args); // do not wait for the result }
internal void OnBackgroundModeChanged(object sender, BackgroundModeChangedEventArgs args) => _connectionManager.SetInBackground(args.IsInBackground);