非同期メソッド呼び出しから返される値を取得できない理由に固執しています。
エラーは発生しません。
ReadAsyncメソッドが完全に実行されないため、残りのコード行をステップスルーできません。
助けてください。あなたは私の唯一の希望です...
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<string> 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<string> 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<string> 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);
}