implement xdocument timeout

  • Thread starter Thread starter André Freitas
  • Start date Start date
A

André Freitas

Im using a xDocument with Linq to get the last 10 blog entries. Like this:

XDocument xDocument = XDocument.Load("SOMEURL");
var linq =
from itens in xDocument.Root.Elements("channel").Elements("item").Take(10)
select new
{
title = (string)itens.Element("title"),
link = (string)itens.Element("link")
};
rptBlogFeed.DataSource = linq;
rptBlogFeed.DataBind();

The problem: I already got the blog feed (third-apart) offline a few times,
and when it ocours, if the site is not cached, the user gets a error. I have
encapsulated the code in a TRY clause, and Im returning a "impossible to
connect with blog" in case of error, but the user still gets a long time
waiting the page to load. So I need two things, that I have no idea about
how to reach:

First, load the entire site, and load the blog feeds later, maybe changing a
LOADING message with the correct data, but I dont know how to do that.
Second, implement a timeout in that request (httprequest?), with a two
seconds timeout, or something like that.

If someone can point me a direction I ll be very glad.

All the best,
André
 
Back
Top