public void GetNewsDetails() { GetNewsDetailResponseDTO newsDetail = new GetNewsDetailResponseDTO(); while (storyIDsForDetails.Count > 0) { newsDetail = CIAPI_Global.CIAPI_Client.GetNewsDetail(storyIDsForDetails.Dequeue()); OnNewsReceived(new NewsReceivedArgs(newsDetail.NewsDetail)); } }
public void EveryRequestCanBeMadeAsyncronouslyToPreventHangingYourUIThread() { var gate = new ManualResetEvent(false); GetNewsDetailResponseDTO newsDetailResponseDto = null; _rpcClient.News.BeginGetNewsDetail( "dj", storyId: _ukHeadlines.Headlines[0].StoryId.ToString(), callback: (response) => { newsDetailResponseDto = _rpcClient.News.EndGetNewsDetail(response); gate.Set(); }, state: null); //DoStuffInCurrentThreadyWhilstRequestHappensInBackground(); gate.WaitOne(TimeSpan.FromSeconds(30)); //Never wait indefinately KoanAssert.That(newsDetailResponseDto.NewsDetail.Story, Is.Not.Null.Or.Empty, "You now have the full body of the news story"); //KoanAssert.That(newsDetailResponseDto.NewsDetail.Story, Is.StringContaining("<p>"), "You now have the full body of the news story"); }