c# – 如何在Windows Phone 8上的async方法中使用Messagebox.Show?

前端之家收集整理的这篇文章主要介绍了c# – 如何在Windows Phone 8上的async方法中使用Messagebox.Show?前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
MessageBox生成异常.如何在异步方法中使用MessageBox
  1. private async void Purchheard(object sender,EventArgs e)
  2. {
  3. Debug.WriteLine("Начинаю покупку");
  4. try
  5. {
  6. await CurrentApp.RequestProductPurchaseAsync(ID,false);
  7. if(license.ProductLicenses[ID].IsActive)
  8. {
  9. world.is_freemium=false;
  10. }
  11. }
  12. catch (Exception ex)
  13. {
  14. MessageBox.Show("Finished!");
  15. }
  16. }

解决方法

  1. Dispatcher.BeginInvoke(delegate() { MessageBox.Show("your stuff"); });

猜你在找的C#相关文章