I am trying to access the UI thread in C# for windows phone 8. So far I got this. However, once it runs SmartDispatcher
, it jumps to finally with receipt == null
.
I got the SmartDispatcher class from this website(http://www.jeff.wilcox.name/2010/04/propertychangedbase-crossthread/). I was wondering if other people had this problem and how to solve it.
private async void purchaseProduct()
{
try{
li = await Store.CurrentApp.LoadListingInformationAsync();
SmartDispatcher.BeginInvoke(async delegate()
{
receipt = await Store.CurrentApp.RequestProductPurchaseAsync(package_id, true);
});
}
catch
{
DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR));
}
finally
{
if(receipt != null)
{
parseXML(package_id);
prepData();
httpPostData();
Store.CurrentApp.ReportProductFulfillment(package_id);
}
}
}