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!");
}
}
Not sure why the accepted answer doesn't work, but here is a working example for .NET 4.5
var dg = new Action(() => { MessageBox.Show(msg, name); });
Dispatcher.CurrentDispatcher.BeginInvoke(dg);
Anonymous methods and delegates
CS0120: An object reference is required for the nonstatic field, method, or property 'foo'
Dispatcher.BeginInvoke(delegate() { MessageBox.Show("your stuff"); });
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With