在MessageBox
上生成异常。如何在MessageBox
方法中使用async
?
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!");
}
}
答案 0 :(得分:4)
不确定为什么接受的答案不起作用,但这是.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'
答案 1 :(得分:2)
Dispatcher.BeginInvoke(delegate() { MessageBox.Show("your stuff"); });