Search code examples
c#winformsawesomium

Awesomium "LoadingFrameComplete" is firing too many times


Just recently began tinkering with Awesomium, it's very cool and much better than the stock webBrowser for WinForms.

However, when I use the _LoadingFrameComplete method to determine if the page has loaded, it seems to be firing 10+ times (when used on Facebook, 2 times when navigating to google.com)

I am trying to get the comparable method of webBrowser1_DocumentCompleted (which only fires one time, after the document has completed).

Is this a 'me' problem, or am I using the wrong methods to check whether the website has finished loading completely.

I'm using Visual C# 2010 Edition

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace Debugging_Problems
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {

            string searchURL = textBox1.Text;
            webControl1.Source = new Uri(searchURL);


        }

        private void Awesomium_Windows_Forms_WebControl_LoadingFrameComplete(object sender, Awesomium.Core.FrameEventArgs e)
        {
            richTextBox1.AppendText("Completed.\n");
        }




    }
}

Solution

  • You need to use IsMainFrame

    private void Awesomium_Windows_Forms_WebControl_LoadingFrameComplete(object sender, Awesomium.Core.FrameEventArgs e)
    {
        if (e.IsMainFrame)
        {
            richTextBox1.AppendText("Completed.\n");
        }
    }