Windows phone 8 如何在windows phone 8上维护会话

Windows phone 8 如何在windows phone 8上维护会话,windows-phone-8,Windows Phone 8,我想在windows phone 8应用程序上维护会话。如何在WP8中维护用户会话在启动、关闭、激活或停用应用程序时,会触发一些事件来通知您。这些事件处理程序可以在Wp8应用程序的App.xaml.cs文件中看到 // Code to execute when the application is launching (eg, from Start) // This code will not execute when the application is reactivated private

我想在windows phone 8应用程序上维护会话。如何在WP8中维护用户会话在启动、关闭、激活或停用应用程序时,会触发一些事件来通知您。这些事件处理程序可以在Wp8应用程序的App.xaml.cs文件中看到

// Code to execute when the application is launching (eg, from Start)
// This code will not execute when the application is reactivated
private void Application_Launching(object sender, LaunchingEventArgs e)
{
}

// Code to execute when the application is activated (brought to foreground)
// This code will not execute when the application is first launched
private void Application_Activated(object sender, ActivatedEventArgs e)
{
}

// Code to execute when the application is deactivated (sent to background)
// This code will not execute when the application is closing
private void Application_Deactivated(object sender, DeactivatedEventArgs e)
{
}

// Code to execute when the application is closing (eg, user hit Back)
// This code will not execute when the application is deactivated
private void Application_Closing(object sender, ClosingEventArgs e)
{
}
另请参见此图,该图来自Microsoft的pdf:

因此,接下来要做的事情是放置适当的代码,以便在应用程序的独立存储中保存和检索数据。读取存储的xml文件的以下代码可能就是一个例子:

XElement doc;
using (var isoStoreStream = new IsolatedStorageFileStream("TimeSpaceData.xml", FileMode.Open, isoStoreFile))
{
    doc = XElement.Load(isoStoreStream);
}

return doc;
XElement pDoc = GetXElementYouWantToSave();
using (var isoStoreStream = new IsolatedStorageFileStream("TimeSpaceData.xml", FileMode.Create, isoStoreFile))
{
    pDoc.Save(isoStoreStream);
}
以下代码将保存一个xml文件:

XElement doc;
using (var isoStoreStream = new IsolatedStorageFileStream("TimeSpaceData.xml", FileMode.Open, isoStoreFile))
{
    doc = XElement.Load(isoStoreStream);
}

return doc;
XElement pDoc = GetXElementYouWantToSave();
using (var isoStoreStream = new IsolatedStorageFileStream("TimeSpaceData.xml", FileMode.Create, isoStoreFile))
{
    pDoc.Save(isoStoreStream);
}

请发布具体问题,说明您想要什么、尝试了什么以及什么不适合您。希望像我们在ASP.NET中使用的那样维护用户会话以跟踪用户信息。您是否使用过桌面或移动应用程序?它们在处理数据的方式上与web应用程序不同。通常,移动应用程序只有一个用户,其背后有文件系统/独立存储。这是你需要的吗?是的。我需要移动应用程序。你能发送示例代码吗?