I am developing an phonegap application i just try to show a circular progress dialog while loading a page, i achieved this in android usingphonegap plugins, when i try to show a Message box from windows native in phonegap using plugin it tells that 'Invalid cross-thread access.'
here is my code
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Phone.Shell;
using System.Windows;
namespace WPCordovaClassLib.Cordova.Commands
{
public class Echo : BaseCommand
{
public void echo(string options)
{
MessageBox.Show("Are you sure?", "Delete Item", MessageBoxButton.OKCancel);
}
}
}
my screen shot
My javascript call
cordova.exec( function(){}, function(){}, "Echo","echo", ["input string"]);
The callback is probably not on the ui thread, it's probably why you get this error just dispatching it back to the ui thread should solve the problem:
public void echo(string options)
{
Deployment.Current.Dispatcher.BeginInvoke(() =>
{
MessageBox.Show("Are you sure?", "Delete Item", MessageBoxButton.OKCancel);
});
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.