public void GetProjects(string rootUrl, string userName, string password, GetProjectsCompleteDelegate complete, Action<Exception> onError) { WebClientXml webClient = new WebClientXml { AuthenticationType = AuthenticationTypeEnum.Base64EncodeInHeader, UserName = userName, Password = password }; rootUrl = GetRootUrl(rootUrl); webClient.DownloadXmlAsync(rootUrl + "/api/xml", onSuccess: doc => { if (doc.Root == null) { onError(new Exception("No results returned")); return; } HudsonBuildDefinition[] buildDefinitions = doc.Root .Elements("job") .Select(projectXml => new HudsonBuildDefinition(rootUrl, projectXml)) .ToArray(); complete(buildDefinitions); }, onError: OnError(onError)); }