private SessionManager(Configuration.ICredentials credentials) { __Credentials = credentials; __TimerAccountCheck.Elapsed += async(object sender, System.Timers.ElapsedEventArgs e) => { await StatusTimerElapsed(); }; if (__Credentials.IsUserLoggedIn()) { Initialize(); } __Credentials.OnCredentialsChanged += (Configuration.ICredentials creds) => { __IsStatusReceived = false; if (creds.IsUserLoggedIn()) { Initialize(); } else { UnInitialize(); } }; ApiServices.Instance.AlternateHostsListUpdated += () => { if (!__IsStatusReceived) { RequestStatusCheck(); } }; }
private void StartBackgroundChecker() { if (__IsActive) { return; } if (!__Credentials.IsUserLoggedIn()) { return; // User not loged-in () no registered sesion - nonthing to check } __IsActive = true; // execute first check immediately // Do not call 'DoCheckAccountStatus ()' directly to avoid checking from main thread __TimerAccountCheck.Interval = 1; __TimerAccountCheck.Start(); }