我有一个每隔一小时运行一次的定期任务。第一次运行此任务时,它将生成一些值。我需要在下次运行任务时访问此值。我怎样才能实现这一目标,最佳选择是什么?
答案 0 :(得分:0)
实现此目的的一种方法是将数据保存在Isolated Storage
中这是一个让你前进的quick start guide。
保存的基础知识:
IsolatedStorageSettings settings = IsolatedStorageSettings.ApplicationSettings;
// txtInput is a TextBox defined in XAML.
if (!settings.Contains("userData"))
{
settings.Add("userData", txtInput.Text);
}
else
{
settings["userData"] = txtInput.Text;
}
settings.Save();
并检索:
if (IsolatedStorageSettings.ApplicationSettings.Contains("userData"))
{
txtDisplay.Text +=
IsolatedStorageSettings.ApplicationSettings["userData"] as string;
}