后台代理,IsolatedStorage和Mutexs-Microsoft是否遵循最佳做法的示例? [英] Background Agents, IsolatedStorage, and Mutexs - Microsoft Sample following best practices?
问题描述
Microsoft的后台代理示例(此页面,在后台文件传输,代理中和警报"部分),示例代码将连接到应用的隔离状态
在OnInvoke方法中存储:
The Background Agent Sample from Microsoft (this page, in the background file transfers, agents, and alarms section), the sample code connects to the app's isolated
storage in the OnInvoke method:
IsolatedStorageSettings
IsolatedStorageSettings
设置= IsolatedStorageSettings .ApplicationSettings;
settings = IsolatedStorageSettings.ApplicationSettings;
TweetSearchTerm =设置[
TweetSearchTerm = settings[
" searchTerm" ].ToString();
"searchTerm"].ToString();
//从库中获取推文
// Get the tweets from the library
TwitterHelper .GetFirstTweet(TweetSearchTerm,tweet =>
TwitterHelper.GetFirstTweet(TweetSearchTerm, tweet =>
{
//如果这无效或与最近看到的推文相同,则不要做任何工作
// Don't do any work if this is invalid or the same as the most recently-seen tweet
如果 ( tweet.Id!= 推特 .InvalidId&& tweet.Id!=设置[ "lastTweetId" ].ToString())
if (tweet.Id != Tweet.InvalidId && tweet.Id != settings["lastTweetId"].ToString())
{
设置[
" lastTweetId" ] = tweet.Id;
"lastTweetId"] = tweet.Id;
settings.Save();
settings.Save();
//显示面包
// Show the toast
ToastHelper . ShowToast(tweet.AuthorAlias,tweet.TweetText, 新 Uri ( "//DetailsPage.xaml?id =" UriKind .Relative));
ToastHelper.ShowToast(tweet.AuthorAlias, tweet.TweetText, new Uri("/DetailsPage.xaml?id=" + tweet.Id, UriKind.Relative));
//检查点内存,因此我们可以看到磁贴更新需要多少空间
// Checkpoint memory so we can see how much more the tile update takes
beforeTileMemory =
beforeTileMemory =
DeviceStatus .ApplicationPeakMemoryUsage;
DeviceStatus.ApplicationPeakMemoryUsage;
//更新磁贴
// Update the tile
TileHelper . UpdateTile( 新 ExtendedTileData
TileHelper.UpdateTile(new ExtendedTileData
{
FrontText =
FrontText =
最新推文"
"latest tweet",
FrontTitle = TweetSearchTerm,
FrontTitle = TweetSearchTerm,
BackText = tweet.TweetText,
BackText = tweet.TweetText,
BackTitle = tweet.AuthorAlias,
BackTitle = tweet.AuthorAlias,
BackImage = tweet.AvatarUri,
BackImage = tweet.AvatarUri,
});
}
However, Best Practices (this page, Communication between foreground and background section) says to use a Mutex for non-audio agents. After following some StackOverflow
threads, it should be a named Mutex.
Can the microsoft sample be fixed so it followes that best practices?
All of the StackOverflow threads say the mutex code is the same for all .net apps but that doens't help for someone new to mutexs.
However, Best Practices (this page, Communication between foreground and background section) says to use a Mutex for non-audio agents. After following some StackOverflow
threads, it should be a named Mutex.
Can the microsoft sample be fixed so it followes that best practices?
All of the StackOverflow threads say the mutex code is the same for all .net apps but that doens't help for someone new to mutexs.
推荐答案
好,我遇到了同样的问题,请问有人可以向我们展示如何实现Mutex与IsolatedStorageFile一起使用.
Ok i am having the same problem, Can any one shows us how to implement Mutex to use with IsolatedStorageFile please.
这篇关于后台代理,IsolatedStorage和Mutexs-Microsoft是否遵循最佳做法的示例?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!