I am trying to open multiple URLs in my application in sequential order after few seconds of wait. But I am getting below exception while running my project. I am putting my code also here, please let me know what I am doing wrong and what is the best way to implement this requirement. Please let me know if you need any other information about my project configuration.
Exception:
A first chance exception of type 'System.NotImplementedException' occurred in WebKitBrowser.dll
A first chance exception of type 'System.UriFormatException' occurred in System.dll
A first chance exception of type 'System.InvalidCastException' occurred in WebKitBrowser.dll
A first chance exception of type 'System.InvalidCastException' occurred in WebKitBrowser.dll
A first chance exception of type 'System.InvalidCastException' occurred in WebKitBrowser.dll
The thread 0x3b8c has exited with code 259 (0x103).
The thread 0xf04 has exited with code 259 (0x103).
The program '[0x2F30] WebKitProject.vshost.exe: Program Trace' has exited with code 0 (0x0).
The program '[0x2F30] WebKitProject.vshost.exe' has exited with code 0 (0x0).
Program:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading;
using System.Windows.Forms;
using WebKit.Interop;
namespace WebKitProject
{
public partial class Form1 : Form
{
private string[] urls = new string[] { "http://www.google.com", "http://www.whatsmyip.org", "http://www.bling.com", "http://www.facebook.com" };
int urlPointer = 0;
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
openBrowser(sender, e);
}
private void openBrowser(object sender, EventArgs e)
{
if (urlPointer < urls.Length)
{
String urlStr = urls[urlPointer];
urlPointer++;
this.webKitBrowser1.DocumentCompleted += new WebBrowserDocumentCompletedEventHandler(webKitBrowser1_Completed);
webKitBrowser1.Navigate(urlStr);
}
}
void webKitBrowser1_Completed(object sender, WebBrowserDocumentCompletedEventArgs e)
{
System.Timers.Timer timer = new System.Timers.Timer(5000);
timer.Elapsed += new System.Timers.ElapsedEventHandler(openBrowser);
timer.Start();
}
}
}