2012-09-13 85 views
0

我想從我的應用程序中顯示敬酒通知,而不是來自推送通知的代碼。從WP7中的代碼敬酒通知

像我的應用程序正在運行,我打開通話任務,並在5秒後,我想在該通話屏幕上顯示吐司通知由於我的應用程序運行在後臺及其obscured狀態。

這裏是我的代碼,我使用Coding4fun工具包:

private void RunBackgroundWorker() 
     { 
      PhoneCallTask callTask = new PhoneCallTask(); 
      callTask.PhoneNumber = "03336329631"; 
      callTask.DisplayName = "Arslan"; 
      callTask.Show(); 

      BackgroundWorker backroungWorker = new BackgroundWorker(); 

      backroungWorker.DoWork += ((s, args) => 
      { 
       Thread.Sleep(5000); 
      }); 

      backroungWorker.RunWorkerCompleted += ((s, args) => 
      { 
       this.Dispatcher.BeginInvoke(() => 
       { 
        var toast = new ToastPrompt 
        { 
         Title = "Simple usage", 
         Message = "Message", 
         ImageSource = new BitmapImage(new Uri("..\\ApplicationIcon.png", UriKind.RelativeOrAbsolute)) 
        }; 
        toast.Show(); 
       } 
      ); 
      }); 
      backroungWorker.RunWorkerAsync(); 
     } 

回答