private void SetupConnectionTimer() { Debug.WriteLine("SetupConnectionTimer..."); Debug.WriteLine("Trying to authorize..."); isAuthorized = Transmitter.Authorize(); Debug.WriteLine("Is authorized: " + isAuthorized); Debug.WriteLine("Setting up connection timer... Interval: " + CONNECTION_INTERVAL); connectTimer = new Timer(); connectTimer.Interval = CONNECTION_INTERVAL; connectTimer.Tick += (o, e) => { if (!isAuthorized) { Debug.WriteLine("Trying to authorize..."); isAuthorized = Transmitter.Authorize(); } }; if (isAuthorized) { Debug.WriteLine("ConnectAndSetup..."); ConnectAndSetup(); connectTimer.Enabled = false; } else { connectTimer.Start(); } }