1
votes

I'm using Watin like so:

private IE myie;
private void button1_Click(object sender, EventArgs e)
{
    try
    {
        myie = new IE();
    }
    catch (Exception ex)
    {
        return;
    }

    myie.GoTo("http://www.google.com");
    myie.WaitForComplete();

}

The problem is, however, once browser window is opened - my C# app starts to consume CPU. According to task manager - in IDLE state my program consumes from 7% to 20% CPU power. (I have AMD 2core 5000+)

Once you close the IE instance (window) - CPU usage problem disappears, so the problem lies somewhere within Watin.

Who do I fix it? What causes CPU drain?

Here, proof:

enter image description here

Project: download on skydrive

Can anybody confirm the bug? Or maybe it's just my PC fails at some point

1
new IE window instance. More info here: watin.orgAlex
I am curious, what else do you have running along with this project? I have been using WatiN for years and haven't had this issue.Brian
@MiserableVariable I don't understand what you mean by this! @Brian nothing! Only this one project. One simple line of code causes CPU drain: IE myie = new IE("http://www.google.com"); on my PC!! I have tried changing Framework to 3.5 instead of 4, tried to change Bits (x64, x86), tried to tick "optimization", "unsafe code".. nothing is helping..Alex
Are you sure it's not IE itself causing the drain? Try opening something less stressful, like notepad.Immortal Blue
Its just you. Confirmed.Ritch Melton

1 Answers

1
votes

Keep in mind - and I am sure you know this already - WatiN is open-source so, there will be bugs in it. Like you, I get a spike of CPU usage when launching the form in both IE and Firefox; but returns to normal in a pretty short order. My advice to you would be to reach out to the WatiN Team. I have posted my code below as well:

namespace WindowsFormsApplication1
{
    using System;
    using System.Windows.Forms;
    using WatiN.Core;

    public partial class Form1 : System.Windows.Forms.Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
               IE testIE = new IE("http://www.google.com");
               //FireFox testFF = new FireFox("http://www.google.com");
            }

            catch (Exception exc)
            {
               MessageBox.Show(exc.Message);
            }
         }
     }
 }