/// <summary> /// Gets the selected movie center XML movie scheduel. /// </summary> /// <param name="movieCenter">Specific MovieCenter object, which contains the feed URL of the movie center.</param> /// <returns>Task which contains the XML in the result parameter.</returns> private async Task<string> GetXmlData(MovieCenter movieCenter) { try { HttpClient client = new HttpClient(); var content = await client.GetStringAsync(movieCenter.FeedUrl); //content = await client.GetStringAsync("http://www.asgasdgash.com/"); return await Task.Run(() => content.ToString()); } catch (HttpRequestException e) { throw new Exception(e.StackTrace); } }
/// <summary> /// Gets the XML from the result in the Task when it is completed and sets the private variables to the value of the results. /// If it encounters a problem with the service it sets the value to null. /// </summary> /// <param name="movieCenter">Specific MovieCenter object, which contains the feed URL of the movie center.</param> public void GetXmlResult(MovieCenter movieCenter) { Task<string> resultTask = null; resultTask = GetXmlData(movieCenter); try { _xmlData = resultTask.Result; } catch (Exception) { _xmlData = null; } }