我试图加载和读取应用程序启动一个设置文件,时间大约90%,在await GetFileAsync("filename.xml");
永远不会返回,因此,悬挂应用。
关于有四分之一的时间,如果我通过代码,它会实际上将返回并阅读该文件。
下面的代码的一个非常简化的版本:
App.xaml.cs:
protected override void OnLaunched(LaunchActivatedEventArgs args)
{
FileLoader.Load().Wait();
// File-load dependent stuff
}
FileLoader.cs:
public async static Task Load()
{
StorageFolder folder = ApplicationData.Current.LocalFolder;
StorageFile file;
bool fileExists = true;
try
{
// The following line (often) never returns
file = await folder.GetFileAsync("filename.xml");
{
catch
{
fileExists = false;
}
// Do stuff with loaded file
}
如果我看的输出窗口在Visual Studio中,经过一段时间的等待,我得到"The thread '<No Name>' (0x30c) has exited with code 0 (0x0)."
有没有人有这里发生了什么的任何想法?