Search code examples
c#windows-phone-8

how can i use Messagebox.Show in async method on Windows Phone 8?


Exception generated on MessageBox. How can I use MessageBox in async method?

private async void Purchheard(object sender,EventArgs e)
{
    Debug.WriteLine("Начинаю покупку");
    try
    {
        await CurrentApp.RequestProductPurchaseAsync(ID,false);
        if(license.ProductLicenses[ID].IsActive)
        {
            world.is_freemium=false;
        }
    }
    catch (Exception ex)
    {
        MessageBox.Show("Finished!");
    }
}

Solution

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