private void RefreshNewsAsync(Action onSuccess, Action<Exception> onError) { var client = new Client(RPC_URI); client.BeginLogIn(USERNAME, PASSWORD, ar => { try { client.EndLogIn(ar); client.BeginListNewsHeadlines(ApplicationSettings.Instance.CategoryCode, ApplicationSettings.Instance.MaxCount, ar2 => { try { var resp = client.EndListNewsHeadlines(ar2); News = resp.Headlines; _client.BeginLogOut(ar3 => _client.EndLogOut(ar3), null); onSuccess(); } catch (Exception exc) { onError(exc); } }, null); } catch (Exception exc) { onError(exc); } }, null); }