Note that there are some explanatory texts on larger screens.

plurals
  1. POCode not executing within nested async methods
    text
    copied!<p>I'm stuck on why I am not able to get a value returned from an async method call.</p> <p>I do not receive any errors.</p> <p>The <strong>ReadAsync</strong> method does not fully execute leaving me unable to step through remaining lines of code.</p> <p>Please help. You are my only hope...</p> <pre><code> protected override void OnNavigatedTo(NavigationEventArgs e) { QuoteParameters quote = e.Parameter as QuoteParameters; Debug.Assert(quote != null); var task = _viewModel.GenerateQuote(quote); string address = task.Result; webView.Source = new Uri(address); } public async Task&lt;string&gt; GenerateQuote(QuoteParameters quote) { var documentedQuote = quote.Convert(); var task = QuoteGenerator.Execute(documentedQuote); string filePath = await task; **// EXECUTION STOPS AT THIS POINT!** return filePath; } public async static Task&lt;string&gt; Execute(QuoteParameters quote) { string html = string.Empty; foreach (var service in quote.Services) { var quoteTemplateTask = IO.ReadAsync(TEMPLATES_DIRECTORY, DOC_TEMPLATE); string quoteTemplate = await quoteTemplateTask; var serviceTemplateTask = IO.ReadAsync(TEMPLATES_DIRECTORY, SERVICE_TEMPLATE); string serviceTemplate = await serviceTemplateTask; var serviceAppliedTemplate = Apply(quoteTemplate, quote.Services, serviceTemplate); var materialTemplate = IO.ReadAsync(TEMPLATES_DIRECTORY, MATERIAL_TEMPLATE); html = Apply(serviceAppliedTemplate, service.Materials, await materialTemplate); } return await SaveAsync(html); } public static async Task&lt;string&gt; ReadAsync(string directoryExtension, string fileName) { string filePath = BuildPath(directoryExtension, fileName); string directoryName = Path.GetDirectoryName(filePath); StorageFolder storageFolder = await StorageFolder.GetFolderFromPathAsync(directoryName); StorageFile storageFile = await storageFolder.GetFileAsync(fileName); **// EXECUTION STOPS HERE** IRandomAccessStream randomAccessStream = await storageFile.OpenAsync(FileAccessMode.Read); IInputStream inputstream = randomAccessStream.GetInputStreamAt(0); DataReader dataReader = new DataReader(inputstream); var numberOfBytesLoaded = dataReader.LoadAsync((uint)randomAccessStream.Size); return dataReader.ReadString(await numberOfBytesLoaded); } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload