public void ReloadApp() { var wasConnected = MqttConnection.IsConnected; MqttConnection.Connect(); // Reinitialize workers only if client was connected to the server before if (wasConnected) { MqttConnection.InitializeWorkers(); } }