public override Task <Response> GetResponseAsync(CancellationToken cancellationToken) { var tcs = new TaskCompletionSource <Response> (); cancellationToken.Register(() => tcs.TrySetCanceled()); request.PerformRequest((resposeData, urlResponse, err) => { Response result = null; try { if (err != null) { throw new Exception(err.LocalizedDescription); } result = new FoundationResponse(resposeData, urlResponse); } catch (Exception ex) { tcs.TrySetException(ex); return; } tcs.TrySetResult(result); }); return(tcs.Task); }
private void Initialize() { Style = UITableViewStyle.Plain; string url = "https://api.twitter.com/1/statuses/public_timeline.xml"; TWRequest request = new TWRequest(new NSUrl("https://api.twitter.com/1/statuses/friends_timeline.xml"), null, TWRequestMethod.Get); request.Account = TwitterAccount.twitterAccount; request.PerformRequest((responseData, urlResponse, error) => { Root = new RootElement("Timeline"); XmlDocument doc = new XmlDocument(); doc.LoadXml(responseData.ToString()); Section timeline = new Section("Timeline"); foreach (XmlNode node in doc.DocumentElement.ChildNodes) timeline.Add (new TweetElement(new Tweet(node))); Root.Add (timeline); this.ReloadData(); }); }