I'm acessing a webservice in a constant loop but after a few requests the server returns a 503 error which i assume that might be caused by the num of repetitive equests. (would you agree with me?)What i would like to do is, based on the below link question, create a retry function that attemps to load the xml a couple number of times, waiting a few seconds in each attempt."C# cleanest way to write retry logic?"\[code\]foreach (var item in ListofItems){XDocument.Load(URL) //this returns .... //handle xml data}\[/code\]The above code might return the exception described(503) and i would like to readapt the extention method defined as answer in the question that I've linked to this post. If successfuly accomplish it should return the XmlDocument resultant from the request. This was my attempt. \[code\]static XDocument RetryXMLLoadAction(Action action, int numRetries, int retryTimeout) { if (action == null) throw new ArgumentNullException("action"); // slightly safer... do { try { XDocument result = action(); return result; } catch { if (numRetries <= 0) throw; // improved to avoid silent failure else Thread.Sleep(retryTimeout); } } while (numRetries-- > 0); }\[/code\]