I'm doing an Universal Windows Platform app with Visual Studio and i'm facing a very strange problem. It's a Background Task on a Windows Runtime Component. The Background task executes without problem if the problematic part of code is removed.
When the code is reached the first sentence (WebRequest request = WebRequest.Create(_finalURI);
) is executed but WebResponse response = await request.GetResponseAsync();
stops immediately the background task, without exception, without anything. Pretty weird.
WebRequest request = WebRequest.Create(_finalURI);
WebResponse response = await request.GetResponseAsync(); // Here it closes
Stream dataStream = response.GetResponseStream();
StreamReader reader = new StreamReader(dataStream);
textResponse = reader.ReadToEnd();
This is a very rare situation for me. I uploaded a video to YouTube so you can see it as it happens. I've been through this more than two hours :( and keep trying.
EDIT:
I've changed to the class HttpClient
and it's the same behavior.
var httpClient = new HttpClient();
textResponse = await httpClient.GetStringAsync(_finalURI); // Here it closes
httpClient.Dispose();
EDIT 2:
Method signature, as requested by Scott Chamberlain:
public async Task<ArticleList> GetArticleList(ArticleAttributes attributes,
ImageResFromAPI imageres, string singleArticle)