Hi, I had created a BHO application with the help of http://www.codeproject.com/KB/cs/Attach_BHO_with_C_.aspx?fid=447248&df=90&mpp=25&noise=3&sort=Position&view=Quick&fr=51&select=2421069
If I Build the source code obtained in above article, the CPU usage is increased to 70-80% How can I reduce this?
In the above article, instead of Document complete event handler, i used progresschange event handler.
In the foreach loop, I used to check the tagname of every tag of a web page, while building the above code (or after registering the dll), the CPU usage was going on increasing from 10-80 percent which may cause problems if there is web page with lot of data(elements).....
I want to avoid this, Is there any method such that i can get all the tagnames of all the tag present in a web page. Please suggest something such that i can avoid this problem. Thanks... The code which causes problem is in bold characters. For each and every tag element found, It has display the message box containing the tagname of the tag element.
The code where I get problem is:
public void onProgressChange(int Progress, int ProgressMax)
{
document = (HTMLDocument)webBrowser.Document;
foreach(IHTMLElement tempElement in (IHTMLElementCollection)document.documentElement.all)
{
System.Windows.Forms.MessageBox.Show(" Tagname:"+ tempElement.tagname);
}
}
public int SetSite(object site)
{
if (site != null)
{
webBrowser = (WebBrowser)site;
webBrowser.ProgressChange += new DWebBrowserEvents2_ProgressChangeEventHandler(this.onProgressChange);
}
else
{
webBrowser.ProgressChange = new DWebBrowserEvents2_ProgressChangeEventHandler(this.onProgressChange);
webBrowser = null;
}
return 0;
}
This Event is generated repeatedly. How to reduce CPU usage?