我已经用谷歌搜索了它,但还没找到任何东西。 控制台显示:
The program "[2952] backgroundTaskHost.exe" has exited with the code 1 (0x1)
MainProject获得了Backgroundtask的引用。该任务在等待fileIO阅读器时退出。
StorageFile sampleFile = await storageFolder.GetFileAsync("Klasse.txt");
Stufe = await FileIO.ReadTextAsync(sampleFile);
在我已经调用另一个FileIO Reader之前,但任务没有退出
StorageFile sampleFile = await storageFolder.GetFileAsync("Facher.txt");
Fach = await FileIO.ReadTextAsync(sampleFile);
总而言之:
namespace BackgroundTask
{
public sealed class BackgroundTask : IBackgroundTask
{
string Stufe = "";
string Fach = "";
BackgroundTaskDeferral _deferral;
public async void Run(IBackgroundTaskInstance taskInstance)
{
_deferral = taskInstance.GetDeferral();
StorageFolder storageFolder = ApplicationData.Current.LocalFolder;
//GetFächer
try
{
StorageFile sampleFile = await storageFolder.GetFileAsync("Facher.txt");
Fach = await FileIO.ReadTextAsync(sampleFile);
}
catch (Exception e) { }
//GetStufe
try
{
StorageFile sampleFile = await storageFolder.GetFileAsync("Klasse.txt");
Stufe = await FileIO.ReadTextAsync(sampleFile);
}
catch (Exception e) { Debug.WriteLine(e); }
_deferral.Complete();
[...]
}
}
答案 0 :(得分:0)
我不得不把完整的标签放在最后。现在它可以工作