I'd like to use a JavaScript library from within a ScheduledTaskAgent on Windows Phone 8. We use this library across our mobile platforms so we don't have to write N versions of it.
I thought I'd be able to do that with a WebBrowser within a ScheduledTaskAgent but I'm running into cross threading issues if I execute this outside of a Dispatcher.BeginInvoke and a System.UnauthorizedAccess exception (claiming I need ID_CAP_WEBBROWSERCOMPONENT despite having that in my application's WMAppManifest.xml) when inside of Dispatcher.BeginInvoke like so:
static ScheduledAgent()
{
// Subscribe to the managed exception handler
Deployment.Current.Dispatcher.BeginInvoke(delegate
{
Application.Current.UnhandledException += UnhandledException;
client = new WebBrowser();
client.NavigateToString("<html><body><script src='https://...path to library...'/></body></html>");
});
}
Has anyone done anything like this before successfully? I can't believe I'm the first person to want to run JavaScript from a background scheduled task on Windows Phone.