我正在编写一个程序,用于在Azure数据库和SQLite本地数据库上存储测验问题的JSON文件(如果您没有互联网,则可以离线同步)。我在我的代码中使用了异步方法,我的Console.WriteLine()
没有触发它们。
我是Asynchronous函数调用的新手,并且遵循此处的Xamarin大学教程: https://www.youtube.com/watch?v=HsKjJ6ohjSA
protected async override void OnStart()
{
var fileHelper = DependencyService.Get<IFileHelper>();
var azureService = new AzureService();
var questions = await azureService.GetQuestions(); //isn't being called
//more stuff...
}
上述函数调用下面的函数
public async Task<List<QuizQuestion>> GetQuestions()
{
Console.WriteLine("This is not being called");
await Initialize();
await SyncQuestions();
return await table.ToListAsync();
}
此功能也会调用await Initialize();
public async Task Initialize()
{
//lots of code ...
Console.WriteLine("Path is: " + path); //never output in Console
//more code is here...
}
似乎我的本地数据库没有将我的问题推送到Azure云数据库,我担心函数根本没有被调用,因为我的Console.Writeline()
函数没有显示在我的日志中。这是对的吗?