I have recently created a webview C# Universal Windows application to run on a Raspberry Pi 3 device using Windows IOT.
Here is the code for the program:
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Xml.Linq; //XElement - loads and parses XML
using System.Runtime.InteropServices.WindowsRuntime;
using Windows.Foundation;
using Windows.Foundation.Collections;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Controls.Primitives;
using Windows.UI.Xaml.Data;
using Windows.UI.Xaml.Input;
using Windows.UI.Xaml.Media;
using Windows.UI.Xaml.Navigation;
using System.Threading.Tasks;
using System.Threading;
namespace WindowsIOTBrowser
{
public sealed partial class MainPage : Page
{
public MainPage()
{
this.InitializeComponent();
TaskDelay(); //calls TaskDelay Method
}
public async void TaskDelay()
{
XElement xelement = XElement.Load("URLs.xml"); //loads and reads XML file - located in \WindowsIOTBrowser\WindowsIOTBrowser\bin\x86\Debug\AppX
IEnumerable<XElement> urls = xelement.Elements(); //assigns URLs to variable
while (true) //loops infinitely
{
foreach (var url in urls) //loops and navigates through each URL
{
var value = url.Element("Address").Value;
var delay = url.Element("Delay").Value;
webView.Navigate(new Uri(value));
await Task.Delay(int.Parse(delay) * 1000); //sets page rotation to time set on XML file - In milliseconds * 1000 to get seconds
}
this.NavigationCacheMode = Windows.UI.Xaml.Navigation.NavigationCacheMode.Enabled;
webView.Refresh();
}
}
}
}
This code has a webview that navigates and rotates through webpages found in an XML document with a delay between loading each page. It does this on a infinite loop.
Any help trying to figure out what keeps crashing the application? I feel that it could be a memory leak or cache buildup.
Thanks!