我的程序里的后台agent应该每30s访问一次twitter timeline,然后把最顶端的数据内容获取,显示到tile上,但是这个tile只能在启动agent的时候更新一次,之后就再不会更新了,怎么回事?
  1. protected override void OnInvoke(ScheduledTask task)
  2. {
  3.     ShellToast popupMessage = new ShellToast()
  4.     {
  5.         Title = "My First Agent",
  6.         Content = "Background Task Launched",
  7.     };
  8.     WebClient twitter = new WebClient();
  9.     twitter.DownloadStringCompleted += new DownloadStringCompletedEventHandler(twitter_DownloadStringCompleted);
  10.     twitter.DownloadStringAsync(new Uri("http://api.twitter.com/1/statuses/user_timeline.xml?screen_name=dnivra26"));
  11.     popupMessage.Show();
  12. }
  13. private void twitter_DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e)
  14. {
  15.     if (e.Error != null)
  16.         return;
  17.     XElement xmlTweets = XElement.Parse(e.Result);
  18.     var message2 = (from tweet in xmlTweets.Descendants("status")
  19.                     select tweet.Element("text").Value).FirstOrDefault();
  20.     UpdateAppTile(DateTime.Now.ToString() + message2.ToString());
  21. }
  22. private void UpdateAppTile(string message)
  23. {
  24.     ShellTile appTile = ShellTile.ActiveTiles.First();
  25.     if (appTile != null)
  26.     {
  27.         StandardTileData tileData = new StandardTileData
  28.         {
  29.             BackContent = message
  30.         };
  31.         appTile.Update(tileData);
  32.         //NotifyComplete();
  33.     }
  34. }
复制代码
实习工程师 2# Sampson007 发表于 2012-2-23 10:20:46
每次完成的时候都要调用下NotifyComplete() ,不然任务的调度就会被取消
版主 3# jason.zhou 发表于 2012-3-9 15:35:23
我和你遇到的问题一样,你怎么解决的?
我的代码已经加了NotifyComplete()了,但是还是每次只更新一次就不更新了。
您需要登录后才可以回帖 登录 | 注册

关于我们|手机版|Archiver|DEVDIV.COM ( 京ICP备07040843号 )  

GMT+8, 2012-5-19 17:08

Powered by DEVDIV.COM!

© 2010-2012 DEVDIV.COM Coummunity.

回顶部